Skip to content

Commit 77193b2

Browse files
antlarrj178florimondmancatomchristie
authored
Add a network pytest mark for tests that use the network (#1669)
* 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 <[email protected]> Co-authored-by: Joe <[email protected]> Co-authored-by: Florimond Manca <[email protected]> Co-authored-by: Tom Christie <[email protected]>
1 parent d514312 commit 77193b2

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ filterwarnings =
2121
default:::uvicorn
2222
markers =
2323
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
24+
network: marks tests which require network connection. Used in 3rd-party build environments that have network disabled.
2425

2526
[coverage:run]
2627
omit = venv/*, httpx/_compat.py

tests/client/test_proxies.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def test_transport_for_request(url, proxies, expected):
122122

123123

124124
@pytest.mark.asyncio
125+
@pytest.mark.network
125126
async def test_async_proxy_close():
126127
try:
127128
client = httpx.AsyncClient(proxies={"https://": PROXY_URL})
@@ -130,6 +131,7 @@ async def test_async_proxy_close():
130131
await client.aclose()
131132

132133

134+
@pytest.mark.network
133135
def test_sync_proxy_close():
134136
try:
135137
client = httpx.Client(proxies={"https://": PROXY_URL})

tests/test_timeouts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ async def test_write_timeout(server):
2323

2424

2525
@pytest.mark.usefixtures("async_environment")
26+
@pytest.mark.network
2627
async def test_connect_timeout(server):
2728
timeout = httpx.Timeout(None, connect=1e-6)
2829

0 commit comments

Comments
 (0)