python-httpx/0001-Add-a-network-pytest-mark-for-tests-that-use-the-network.patch
Steve Kowalik ab0f76ecff Accepting request 900750 from home:alarrosa:branches:devel:languages:python
- Update to 0.18.2
  * Added
    - Support for Python 3.10. (Pull #1687)
    - Expose httpx.USE_CLIENT_DEFAULT, used as the default to auth
      and timeout parameters in request methods.
    - Support HTTP/2 "prior knowledge", using
      httpx.Client(http1=False, http2=True).
  * Fixed
    - Clean up some cases where warnings were being issued.
    - Prefer Content-Length over Transfer-Encoding: chunked for
      content= cases.
- Update to 0.18.1
  * Changed
    - Update brotli support to use the brotlicffi package
    - Ensure that Request(..., stream=...) does not auto-generate
      any headers on the request instance.
  * Fixed
    - Pass through timeout=... in top-level httpx.stream()
      function.
    - Map httpcore transport close exceptions to httpx exceptions.
- Add patch (submitted to upstream at gh#encode/httpx#1669) to add
  a pytest marker so we can disable the tests that use the network
  in %check:
  * 0001-Add-a-network-pytest-mark-for-tests-that-use-the-network.patch

OBS-URL: https://build.opensuse.org/request/show/900750
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-httpx?expand=0&rev=3
2021-06-18 11:18:04 +00:00

65 lines
2.2 KiB
Diff

From 55b8ee87b0e57f3dda924e3d01ee8eaa39c4aa81 Mon Sep 17 00:00:00 2001
From: Antonio Larrosa <antonio.larrosa@gmail.com>
Date: Mon, 7 Jun 2021 18:32:29 +0200
Subject: [PATCH] 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.
---
setup.cfg | 1 +
tests/client/test_proxies.py | 2 ++
tests/test_timeouts.py | 1 +
3 files changed, 4 insertions(+)
diff --git a/setup.cfg b/setup.cfg
index c860d819c..eb5451d96 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -18,6 +18,7 @@ combine_as_imports = True
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
[coverage:run]
omit = venv/*, httpx/_compat.py
diff --git a/tests/client/test_proxies.py b/tests/client/test_proxies.py
index 6ea4cbe40..2817d202b 100644
--- a/tests/client/test_proxies.py
+++ b/tests/client/test_proxies.py
@@ -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})
diff --git a/tests/test_timeouts.py b/tests/test_timeouts.py
index 46a8bee8f..c7a665c3b 100644
--- a/tests/test_timeouts.py
+++ b/tests/test_timeouts.py
@@ -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)