Skip to content

Commit 0c896f6

Browse files
authored
Drop support for python 3.6 (#218)
1 parent 8d9e149 commit 0c896f6

File tree

17 files changed

+18
-81
lines changed

17 files changed

+18
-81
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Python
1818
uses: actions/setup-python@v2
1919
with:
20-
python-version: 3.6
20+
python-version: 3.7
2121
- name: Pip cache
2222
uses: actions/cache@v1
2323
with:

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
max-parallel: 5
2121
matrix:
22-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
22+
python-version: ["3.7", "3.8", "3.9", "3.10"]
2323
steps:
2424
- uses: actions/checkout@v2
2525
- name: Set up Python ${{ matrix.python-version }}
@@ -51,7 +51,7 @@ jobs:
5151
- name: Set up Python
5252
uses: actions/setup-python@v2
5353
with:
54-
python-version: 3.6
54+
python-version: 3.7
5555
- name: Pip cache
5656
uses: actions/cache@v1
5757
with:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ Install with pip:
6868
$ pip install respx
6969
```
7070

71-
Requires Python 3.6+ and HTTPX 0.21+.
71+
Requires Python 3.7+ and HTTPX 0.21+.
7272
See [Changelog](https://github.com/lundberg/respx/blob/master/CHANGELOG.md) for older HTTPX compatibility.

docs/examples.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ import respx
9797

9898

9999
@respx.mock
100-
@pytest.mark.asyncio
101100
async def test_async_decorator():
102101
async with httpx.AsyncClient() as client:
103102
route = respx.get("https://example.org/")
@@ -106,7 +105,6 @@ async def test_async_decorator():
106105
assert response.status_code == 200
107106

108107

109-
@pytest.mark.asyncio
110108
async def test_async_ctx_manager():
111109
async with respx.mock:
112110
async with httpx.AsyncClient() as client:

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ Install with pip:
6868
$ pip install respx
6969
```
7070

71-
Requires Python 3.6+ and HTTPX 0.21+.
71+
Requires Python 3.7+ and HTTPX 0.21+.
7272
See [Changelog](https://github.com/lundberg/respx/blob/master/CHANGELOG.md) for older HTTPX compatibility.

docs/versions/0.14.0/mocking.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,3 @@ class MyTestCase(asynctest.TestCase):
250250
assert request.called
251251
assert response.text == "foobar"
252252
```
253-

noxfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
docs_requirements = ("mkdocs", "mkdocs-material", "mkautodoc>=0.1.0")
1010

1111

12-
@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"])
12+
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
1313
def test(session):
1414
deps = ["pytest", "pytest-asyncio", "pytest-cov", "trio", "starlette", "flask"]
1515
session.install("--upgrade", *deps)
@@ -22,12 +22,12 @@ def test(session):
2222
session.run("pytest", "-v", *options)
2323

2424

25-
@nox.session(python="3.6")
25+
@nox.session(python="3.7")
2626
def check(session):
2727
session.install("--upgrade", "flake8-bugbear", "mypy", *lint_requirements)
2828
session.install("-e", ".")
2929

30-
session.run("black", "--check", "--diff", "--target-version=py36", *source_files)
30+
session.run("black", "--check", "--diff", "--target-version=py37", *source_files)
3131
session.run("isort", "--check", "--diff", "--project=respx", *source_files)
3232
session.run("flake8", *source_files)
3333
session.run("mypy")
@@ -39,7 +39,7 @@ def lint(session):
3939

4040
session.run("autoflake", "--in-place", "--recursive", *source_files)
4141
session.run("isort", "--project=respx", *source_files)
42-
session.run("black", "--target-version=py36", *source_files)
42+
session.run("black", "--target-version=py37", *source_files)
4343

4444
session.notify("check")
4545

respx/handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self, transport: httpx.BaseTransport) -> None:
99

1010
def __call__(self, request: httpx.Request) -> httpx.Response:
1111
if not isinstance(
12-
request.stream, # type: ignore[has-type]
12+
request.stream,
1313
httpx.SyncByteStream,
1414
): # pragma: nocover
1515
raise RuntimeError("Attempted to route an async request to a sync app.")
@@ -23,7 +23,7 @@ def __init__(self, transport: httpx.AsyncBaseTransport) -> None:
2323

2424
async def __call__(self, request: httpx.Request) -> httpx.Response:
2525
if not isinstance(
26-
request.stream, # type: ignore[has-type]
26+
request.stream,
2727
httpx.AsyncByteStream,
2828
): # pragma: nocover
2929
raise RuntimeError("Attempted to route a sync request to an async app.")

respx/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def clone_response(response: httpx.Response, request: httpx.Request) -> httpx.Re
3535
response = httpx.Response(
3636
response.status_code,
3737
headers=response.headers,
38-
stream=response.stream, # type: ignore[has-type]
38+
stream=response.stream,
3939
request=request,
4040
extensions=dict(response.extensions),
4141
)

respx/router.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,7 @@ def resolve(self, request: httpx.Request) -> ResolvedRoute:
283283
resolved.response = cast(ResolvedResponseTypes, prospect)
284284
break
285285

286-
if resolved.response and isinstance(
287-
resolved.response.stream, httpx.ByteStream # type: ignore[has-type]
288-
):
286+
if resolved.response and isinstance(resolved.response.stream, httpx.ByteStream):
289287
resolved.response.read() # Pre-read stream
290288

291289
return resolved
@@ -307,9 +305,7 @@ async def aresolve(self, request: httpx.Request) -> ResolvedRoute:
307305
resolved.response = cast(ResolvedResponseTypes, prospect)
308306
break
309307

310-
if resolved.response and isinstance(
311-
resolved.response.stream, httpx.ByteStream # type: ignore[has-type]
312-
):
308+
if resolved.response and isinstance(resolved.response.stream, httpx.ByteStream):
313309
await resolved.response.aread() # Pre-read stream
314310

315311
return resolved

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ universal = 1
33

44
[flake8]
55
max-line-length = 88
6-
ignore = E501,E266,E731,W503,E203,B024
6+
ignore = B024,C408,E203,W503
77
exclude = .git
88
show-source = true
99

@@ -36,7 +36,7 @@ skip_covered = True
3636
show_missing = True
3737

3838
[mypy]
39-
python_version = 3.6
39+
python_version = 3.7
4040
files = respx,tests
4141
pretty = True
4242

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"Operating System :: OS Independent",
2424
"Programming Language :: Python",
2525
"Programming Language :: Python :: 3",
26-
"Programming Language :: Python :: 3.6",
2726
"Programming Language :: Python :: 3.7",
2827
"Programming Language :: Python :: 3.8",
2928
"Programming Language :: Python :: 3.9",
@@ -39,6 +38,6 @@
3938
entry_points={"pytest11": ["respx = respx.plugin"]},
4039
include_package_data=True,
4140
zip_safe=False,
42-
python_requires=">=3.6",
41+
python_requires=">=3.7",
4342
install_requires=["httpx>=0.21.0"],
4443
)

tests/test_api.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from respx.router import MockRouter
1515

1616

17-
@pytest.mark.asyncio
1817
async def test_http_methods(client):
1918
async with respx.mock:
2019
url = "https://foo.bar"
@@ -73,7 +72,6 @@ async def test_http_methods(client):
7372
assert respx.calls.call_count == 8 * 2
7473

7574

76-
@pytest.mark.asyncio
7775
@pytest.mark.parametrize(
7876
"url,pattern",
7977
[
@@ -95,14 +93,12 @@ async def test_url_match(client, url, pattern):
9593
assert response.text == "baz"
9694

9795

98-
@pytest.mark.asyncio
9996
async def test_invalid_url_pattern():
10097
async with MockRouter() as respx_mock:
10198
with pytest.raises(TypeError):
10299
respx_mock.get(["invalid"]) # type: ignore[arg-type]
103100

104101

105-
@pytest.mark.asyncio
106102
async def test_repeated_pattern(client):
107103
async with MockRouter() as respx_mock:
108104
url = "https://foo/bar/baz/"
@@ -127,7 +123,6 @@ async def test_repeated_pattern(client):
127123
assert statuses == [201, 409]
128124

129125

130-
@pytest.mark.asyncio
131126
async def test_status_code(client):
132127
async with MockRouter() as respx_mock:
133128
url = "https://foo.bar/"
@@ -138,7 +133,6 @@ async def test_status_code(client):
138133
assert response.status_code == 404
139134

140135

141-
@pytest.mark.asyncio
142136
@pytest.mark.parametrize(
143137
"headers,content_type,expected",
144138
[
@@ -166,7 +160,6 @@ async def test_headers(client, headers, content_type, expected):
166160
assert response.headers == httpx.Headers(expected)
167161

168162

169-
@pytest.mark.asyncio
170163
@pytest.mark.parametrize(
171164
"content,expected",
172165
[
@@ -184,7 +177,6 @@ async def test_text_encoding(client, content, expected):
184177
assert response.text == expected
185178

186179

187-
@pytest.mark.asyncio
188180
@pytest.mark.parametrize(
189181
"key,value,expected_content_type",
190182
[
@@ -214,7 +206,6 @@ async def test_content_variants(client, key, value, expected_content_type):
214206
assert sync_response.content is not None
215207

216208

217-
@pytest.mark.asyncio
218209
@pytest.mark.parametrize(
219210
"content,headers,expected_headers",
220211
[
@@ -272,15 +263,11 @@ def test_json_post_body():
272263
assert get_route.called
273264

274265

275-
@pytest.mark.asyncio
276266
async def test_raising_content(client):
277267
async with MockRouter() as respx_mock:
278268
url = "https://foo.bar/"
279269
request = respx_mock.get(url)
280-
request.side_effect = httpx.ConnectTimeout(
281-
"X-P",
282-
request=None, # type: ignore[arg-type]
283-
)
270+
request.side_effect = httpx.ConnectTimeout("X-P", request=None)
284271
with pytest.raises(httpx.ConnectTimeout):
285272
await client.get(url)
286273

@@ -301,7 +288,6 @@ async def test_raising_content(client):
301288
assert route.calls.last.response
302289

303290

304-
@pytest.mark.asyncio
305291
async def test_callable_content(client):
306292
async with MockRouter() as respx_mock:
307293
url_pattern = re.compile(r"https://foo.bar/(?P<slug>\w+)/")
@@ -327,7 +313,6 @@ def content_callback(request, slug):
327313
assert request.calls[-1][0].content == b'{"x": "!"}'
328314

329315

330-
@pytest.mark.asyncio
331316
async def test_request_callback(client):
332317
def callback(request, name):
333318
if request.url.host == "foo.bar" and request.content == b'{"foo": "bar"}':
@@ -375,7 +360,6 @@ def _callback(request):
375360
await client.get("https://egg.plant/")
376361

377362

378-
@pytest.mark.asyncio
379363
@pytest.mark.parametrize(
380364
"using,route,expected",
381365
[
@@ -415,7 +399,6 @@ async def test_pass_through(client, using, route, expected):
415399

416400

417401
@respx.mock
418-
@pytest.mark.asyncio
419402
async def test_parallel_requests(client):
420403
def content(request, page):
421404
return httpx.Response(200, text=page)
@@ -433,7 +416,6 @@ def content(request, page):
433416
assert respx.calls.call_count == 2
434417

435418

436-
@pytest.mark.asyncio
437419
@pytest.mark.parametrize(
438420
"method_str, client_method_attr",
439421
[
@@ -476,7 +458,6 @@ def test_pop():
476458

477459

478460
@respx.mock
479-
@pytest.mark.asyncio
480461
@pytest.mark.parametrize(
481462
"url,params,call_url,call_params",
482463
[
@@ -503,7 +484,6 @@ async def test_params_match(client, url, params, call_url, call_params):
503484
assert response.text == "spam spam"
504485

505486

506-
@pytest.mark.asyncio
507487
@pytest.mark.parametrize(
508488
"base,url",
509489
[
@@ -564,7 +544,6 @@ def test_respond():
564544
route.respond(content=Exception()) # type: ignore[arg-type]
565545

566546

567-
@pytest.mark.asyncio
568547
@pytest.mark.parametrize(
569548
"kwargs",
570549
[

0 commit comments

Comments
 (0)