Skip to content

Commit 1e4e87d

Browse files
Support for Python 3.12 (#1444)
* Support for Python 3.12 * Use `assert_called_once_with` and not `called_once_with` * lint fix * Fix `test_pac_file_served_from_disk` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 201d02c commit 1e4e87d

File tree

4 files changed

+30
-20
lines changed

4 files changed

+30
-20
lines changed

.github/workflows/test-library.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,9 @@ jobs:
446446
# NOTE: The latest and the lowest supported Pythons are prioritized
447447
# NOTE: to improve the responsiveness. It's nice to see the most
448448
# NOTE: important results first.
449-
- '3.11'
449+
- '3.12'
450450
- 3.6
451+
- '3.11'
451452
- '3.10'
452453
- 3.9
453454
- 3.8

proxy/http/handler.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,7 @@ def _parse_first_request(self, data: memoryview) -> bool:
292292
return True
293293
# Discover which HTTP handler plugin is capable of
294294
# handling the current incoming request
295-
klass = self._discover_plugin_klass(
296-
self.request.http_handler_protocol,
297-
)
295+
klass = self._discover_plugin_klass(self.request.http_handler_protocol)
298296
if klass is None:
299297
# No matching protocol class found.
300298
# Return bad request response and

tests/http/web/test_web_server.py

+26-15
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,6 @@ def test_on_client_connection_called_on_teardown(mocker: MockerFixture) -> None:
5959
assert _conn.closed
6060

6161

62-
def mock_selector_for_client_read(self: Any) -> None:
63-
self.mock_selector.return_value.select.return_value = [
64-
(
65-
selectors.SelectorKey(
66-
fileobj=self._conn.fileno(),
67-
fd=self._conn.fileno(),
68-
events=selectors.EVENT_READ,
69-
data=None,
70-
),
71-
selectors.EVENT_READ,
72-
),
73-
]
74-
7562
# @mock.patch('socket.fromfd')
7663
# def test_on_client_connection_called_on_teardown(
7764
# self, mock_fromfd: mock.Mock,
@@ -171,16 +158,40 @@ def _setUp(self, request: Any, mocker: MockerFixture) -> None:
171158
b'GET / HTTP/1.1',
172159
CRLF,
173160
])
174-
mock_selector_for_client_read(self)
161+
self.mock_selector.return_value.select.side_effect = [
162+
[
163+
(
164+
selectors.SelectorKey(
165+
fileobj=self._conn.fileno(),
166+
fd=self._conn.fileno(),
167+
events=selectors.EVENT_READ,
168+
data=None,
169+
),
170+
selectors.EVENT_READ,
171+
),
172+
],
173+
[
174+
(
175+
selectors.SelectorKey(
176+
fileobj=self._conn.fileno(),
177+
fd=self._conn.fileno(),
178+
events=selectors.EVENT_WRITE,
179+
data=None,
180+
),
181+
selectors.EVENT_WRITE,
182+
),
183+
],
184+
]
175185

176186
@pytest.mark.asyncio # type: ignore[misc]
177187
async def test_pac_file_served_from_disk(self) -> None:
188+
await self.protocol_handler._run_once()
178189
await self.protocol_handler._run_once()
179190
self.assertEqual(
180191
self.protocol_handler.request.state,
181192
httpParserStates.COMPLETE,
182193
)
183-
self._conn.send.called_once_with(
194+
self._conn.send.assert_called_once_with(
184195
build_http_response(
185196
200,
186197
reason=b'OK',

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py36,py37,py38,py39,py310,py311
2+
envlist = py36,py37,py38,py39,py310,py311,py312
33
isolated_build = true
44
minversion = 3.21.0
55

0 commit comments

Comments
 (0)