Skip to content
Myr

Add a network pytest mark for tests that use the network (#1669)

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

* Add a network pytest mark for tests that use the network Sometimes it's useful to have the tests that use the network marked so they can be skipped easily when we know the network is not available. This is useful for example on SUSE and openSUSE's build servers. When building the httpx packages (actually, any package in the distribution) the network is disabled so we can assure reproducible builds (among other benefits). With this mark, it's easier to skip tests that can not succeed. * Add a better explanation for the network marker Co-authored-by: Florimond Manca <15911462+florimondmanca@users.noreply.github.com>

authored by Antonio Larrosa · committed by GitHub · parent d514312 · Browse files · 3 files+4 added−0 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: Joe <nigelchiang@outlook.com>
  • Co-authored-by: Florimond Manca <15911462+florimondmanca@users.noreply.github.com>
  • Co-authored-by: Tom Christie <tom@tomchristie.com>

Diff stats

3 files+4 added−0 removed

  • tests:+3 added−0 removed
  • other:+1 added−0 removed

3 files+4 added−0 removed

modified:tests/client/test_proxies.py+2 added
120 unmodified lines
121 assert transport._pool.proxy_origin == url_to_origin(expected)122123124@pytest.mark.asyncio125@pytest.mark.network126async def test_async_proxy_close():127 try:128 client = httpx.AsyncClient(proxies={"https://": PROXY_URL})129 await client.get("http://example.com")130 finally:131 await client.aclose()132133134@pytest.mark.network135def test_sync_proxy_close():136 try:137 client = httpx.Client(proxies={"https://": PROXY_URL})138 client.get("http://example.com")
137 unmodified lines
modified:tests/test_timeouts.py+1 added
21 unmodified lines
22 await client.put(server.url.copy_with(path="/slow_response"), content=data)232425@pytest.mark.usefixtures("async_environment")26@pytest.mark.network27async def test_connect_timeout(server):28 timeout = httpx.Timeout(None, connect=1e-6)2930 async with httpx.AsyncClient(timeout=timeout) as client:
14 unmodified lines
modified:setup.cfg+1 added
19 unmodified lines
20 error21 default:::uvicorn22markers =23 copied_from(source, changes=None): mark test as copied from somewhere else, along with a description of changes made to accodomate e.g. our test setup24 network: marks tests which require network connection. Used in 3rd-party build environments that have network disabled.2526[coverage:run]27omit = venv/*, httpx/_compat.py28include = httpx/*, tests/*