]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Add a network pytest mark for tests that use the network (#1669)
authorAntonio Larrosa <antonio.larrosa@gmail.com>
Fri, 13 Aug 2021 13:13:43 +0000 (15:13 +0200)
committerGitHub <noreply@github.com>
Fri, 13 Aug 2021 13:13:43 +0000 (14:13 +0100)
* 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>
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>
setup.cfg
tests/client/test_proxies.py
tests/test_timeouts.py

index 2a3bc303f7c310cca9b55e77ed1d38cc752adfd2..de10fa5500b58b1ef8ef87793f7c98724299b770 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -21,6 +21,7 @@ filterwarnings =
   default:::uvicorn
 markers =
   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 setup
+  network: marks tests which require network connection. Used in 3rd-party build environments that have network disabled.
 
 [coverage:run]
 omit = venv/*, httpx/_compat.py
index 6ea4cbe407a419ad1c10d230c1ce0a18a74f8b07..2817d202b9d2cb51f49074d10fe19368fd8df06e 100644 (file)
@@ -122,6 +122,7 @@ def test_transport_for_request(url, proxies, expected):
 
 
 @pytest.mark.asyncio
+@pytest.mark.network
 async def test_async_proxy_close():
     try:
         client = httpx.AsyncClient(proxies={"https://": PROXY_URL})
@@ -130,6 +131,7 @@ async def test_async_proxy_close():
         await client.aclose()
 
 
+@pytest.mark.network
 def test_sync_proxy_close():
     try:
         client = httpx.Client(proxies={"https://": PROXY_URL})
index 46a8bee8fceb0344a55a150a3c16e314cda28deb..c7a665c3bb10d01586cb725cae57d9b3bea61de1 100644 (file)
@@ -23,6 +23,7 @@ async def test_write_timeout(server):
 
 
 @pytest.mark.usefixtures("async_environment")
+@pytest.mark.network
 async def test_connect_timeout(server):
     timeout = httpx.Timeout(None, connect=1e-6)