Skip to content
Myr

Use relative tests directory references (#1052)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Use relative tests directory references * Use absolute TESTS_DIR

authored by Florimond Manca · committed by GitHub · parent ff93a01 · Browse files · 5 files+29 added−17 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Tom Christie <tom@tomchristie.com>

Diff stats

5 files+29 added−17 removed

  • tests:+29 added−17 removed

5 files+29 added−17 removed

modified:tests/client/test_auth.py+5 added-3 removed
16 unmodified lines
17 Response,18)19from httpx._content_streams import ContentStream, JSONStream2021from ..common import FIXTURES_DIR222324def get_header_value(headers, key, default=None):25 lookup = key.encode("ascii").lower()26 for header_key, header_value in headers:27 if header_key.lower() == lookup:
206 unmodified lines
234235236@pytest.mark.asyncio237async def test_netrc_auth() -> None:236 os.environ["NETRC"] = "tests/.netrc"238 os.environ["NETRC"] = str(FIXTURES_DIR / ".netrc")239 url = "http://netrcexample.org"240241 client = AsyncClient(transport=AsyncMockTransport())242 response = await client.get(url)
5 unmodified lines
248249250@pytest.mark.asyncio251async def test_auth_header_has_priority_over_netrc() -> None:250 os.environ["NETRC"] = "tests/.netrc"252 os.environ["NETRC"] = str(FIXTURES_DIR / ".netrc")253 url = "http://netrcexample.org"254255 client = AsyncClient(transport=AsyncMockTransport())256 response = await client.get(url, headers={"Authorization": "Override"})
3 unmodified lines
260261262@pytest.mark.asyncio263async def test_trust_env_auth() -> None:262 os.environ["NETRC"] = "tests/.netrc"264 os.environ["NETRC"] = str(FIXTURES_DIR / ".netrc")265 url = "http://netrcexample.org"266267 client = AsyncClient(transport=AsyncMockTransport(), trust_env=False)268 response = await client.get(url)
342 unmodified lines
added:tests/fixtures/.netrc+3 added
1machine netrcexample.org2login example-username3password example-password
deleted:tests/.netrc-3 removed
1machine netrcexample.org2login example-username3password example-password
added:tests/common.py+4 added
1import pathlib23TESTS_DIR = pathlib.Path(__file__).parent4FIXTURES_DIR = TESTS_DIR / "fixtures"
modified:tests/test_utils.py+17 added-11 removed
14 unmodified lines
15 should_not_be_proxied,16)17from tests.utils import override_log_level1819from .common import FIXTURES_DIR, TESTS_DIR202122@pytest.mark.parametrize(23 "encoding",24 (25 "utf-32",
29 unmodified lines
55 assert guess_json_utf(data) == expected565758def test_bad_get_netrc_login():57 netrc_info = NetRCInfo(["tests/does-not-exist"])59 netrc_info = NetRCInfo([str(FIXTURES_DIR / "does-not-exist")])60 assert netrc_info.get_credentials("netrcexample.org") is None616263def test_get_netrc_login():62 netrc_info = NetRCInfo(["tests/.netrc"])64 netrc_info = NetRCInfo([str(FIXTURES_DIR / ".netrc")])65 expected_credentials = (66 "example-username",67 "example-password",68 )69 assert netrc_info.get_credentials("netrcexample.org") == expected_credentials707172def test_get_netrc_unknown():71 netrc_info = NetRCInfo(["tests/.netrc"])73 netrc_info = NetRCInfo([str(FIXTURES_DIR / ".netrc")])74 assert netrc_info.get_credentials("nonexistant.org") is None757677@pytest.mark.parametrize(
60 unmodified lines
138def test_get_ssl_cert_file():139 # Two environments is not set.140 assert get_ca_bundle_from_env() is None141140 os.environ["SSL_CERT_DIR"] = "tests/"142 os.environ["SSL_CERT_DIR"] = str(TESTS_DIR)143 # SSL_CERT_DIR is correctly set, SSL_CERT_FILE is not set.142 assert get_ca_bundle_from_env() == "tests"144 ca_bundle = get_ca_bundle_from_env()145 assert ca_bundle is not None and ca_bundle.endswith("tests")146147 del os.environ["SSL_CERT_DIR"]145 os.environ["SSL_CERT_FILE"] = "tests/test_utils.py"148 os.environ["SSL_CERT_FILE"] = str(TESTS_DIR / "test_utils.py")149 # SSL_CERT_FILE is correctly set, SSL_CERT_DIR is not set.147 assert get_ca_bundle_from_env() == "tests/test_utils.py"150 ca_bundle = get_ca_bundle_from_env()151 assert ca_bundle is not None and ca_bundle.endswith("tests/test_utils.py")152153 os.environ["SSL_CERT_FILE"] = "wrongfile"154 # SSL_CERT_FILE is set with wrong file, SSL_CERT_DIR is not set.155 assert get_ca_bundle_from_env() is None
2 unmodified lines
158 os.environ["SSL_CERT_DIR"] = "wrongpath"159 # SSL_CERT_DIR is set with wrong path, SSL_CERT_FILE is not set.160 assert get_ca_bundle_from_env() is None161158 os.environ["SSL_CERT_DIR"] = "tests/"159 os.environ["SSL_CERT_FILE"] = "tests/test_utils.py"162 os.environ["SSL_CERT_DIR"] = str(TESTS_DIR)163 os.environ["SSL_CERT_FILE"] = str(TESTS_DIR / "test_utils.py")164 # Two environments is correctly set.161 assert get_ca_bundle_from_env() == "tests/test_utils.py"165 ca_bundle = get_ca_bundle_from_env()166 assert ca_bundle is not None and ca_bundle.endswith("tests/test_utils.py")167168 os.environ["SSL_CERT_FILE"] = "wrongfile"169 # Two environments is set but SSL_CERT_FILE is not a file.165 assert get_ca_bundle_from_env() == "tests"170 ca_bundle = get_ca_bundle_from_env()171 assert ca_bundle is not None and ca_bundle.endswith("tests")172173 os.environ["SSL_CERT_DIR"] = "wrongpath"174 # Two environments is set but both are not correct.175 assert get_ca_bundle_from_env() is None
121 unmodified lines