Skip to content

Commit 59d4a80

Browse files
authored
✅ Add httpx2 test dependency to avoid deprecation warning (fastapi#15603)
1 parent 6cbdde2 commit 59d4a80

6 files changed

Lines changed: 59 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
3030
with:
3131
version: "0.11.4"
32+
enable-cache: "false"
3233
- name: Build distribution
3334
run: uv build
3435
- name: Publish

.github/workflows/test.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ jobs:
8181
uv-resolution: highest
8282
codspeed: codspeed
8383
deprecated-tests: "no-deprecation"
84+
- os: ubuntu-latest
85+
python-version: "3.13"
86+
uv-resolution: highest
87+
deprecated-tests: "no-deprecation"
88+
without-httpx2: true
8489
- os: ubuntu-latest
8590
python-version: "3.14"
8691
coverage: coverage
@@ -129,15 +134,19 @@ jobs:
129134
- name: Install deprecated libraries just for testing
130135
if: matrix.deprecated-tests == 'test-deprecation'
131136
run: uv pip install orjson ujson
137+
- name: Uninstall httpx2 to run tests with httpx
138+
if: matrix.without-httpx2 == 'true'
139+
run: uv pip uninstall httpx2
132140
- name: Reinstall SQLAlchemy without Cython extensions
133141
if: matrix.python-version == '3.14t' && matrix.os == 'ubuntu-latest'
134142
run: "DISABLE_SQLALCHEMY_CEXT=1 uv pip install --force-reinstall --no-binary :all: sqlalchemy"
135143
- run: mkdir coverage
136144
- name: Test
137-
run: uv run --no-sync bash scripts/test-cov.sh
145+
run: uv run --no-sync bash scripts/test-cov.sh $PYTEST_OPTIONS
138146
env:
139147
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.deprecated-tests}}
140148
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.deprecated-tests}}
149+
PYTEST_OPTIONS: ${{ (matrix.without-httpx2 == 'true') && '-W ignore::UserWarning' || '' }}
141150
# Do not store coverage for all possible combinations to avoid file size max errors in Smokeshow
142151
- name: Store coverage files
143152
if: matrix.coverage == 'coverage'

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ docs = [
146146
]
147147
docs-tests = [
148148
"httpx >=0.23.0,<1.0.0",
149+
"httpx2>=2.0.0",
149150
"ruff >=0.14.14",
150151
]
151152
github-actions = [

tests/test_tutorial/test_header_param_models/test_tutorial001.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import importlib
22

33
import pytest
4+
from dirty_equals import IsOneOf
45
from fastapi.testclient import TestClient
56
from inline_snapshot import snapshot
67

@@ -68,7 +69,9 @@ def test_header_param_model_invalid(client: TestClient):
6869
"x_tag": [],
6970
"host": "testserver",
7071
"accept": "*/*",
71-
"accept-encoding": "gzip, deflate",
72+
"accept-encoding": IsOneOf(
73+
"gzip, deflate", "gzip, deflate, zstd"
74+
),
7275
"connection": "keep-alive",
7376
"user-agent": "testclient",
7477
},

tests/test_tutorial/test_header_param_models/test_tutorial003.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import importlib
22

33
import pytest
4+
from dirty_equals import IsOneOf
45
from fastapi.testclient import TestClient
56
from inline_snapshot import snapshot
67

@@ -66,7 +67,9 @@ def test_header_param_model_no_underscore(client: TestClient):
6667
"traceparent": "123",
6768
"x_tag": [],
6869
"accept": "*/*",
69-
"accept-encoding": "gzip, deflate",
70+
"accept-encoding": IsOneOf(
71+
"gzip, deflate", "gzip, deflate, zstd"
72+
),
7073
"connection": "keep-alive",
7174
"user-agent": "testclient",
7275
"save-data": "true",
@@ -105,7 +108,9 @@ def test_header_param_model_invalid(client: TestClient):
105108
"x_tag": [],
106109
"host": "testserver",
107110
"accept": "*/*",
108-
"accept-encoding": "gzip, deflate",
111+
"accept-encoding": IsOneOf(
112+
"gzip, deflate", "gzip, deflate, zstd"
113+
),
109114
"connection": "keep-alive",
110115
"user-agent": "testclient",
111116
},

uv.lock

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)