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>
This commit is contained in:
Abhinav Singh 2024-08-10 09:33:49 +05:30 committed by GitHub
parent 201d02ce72
commit 1e4e87d515
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 20 deletions

View File

@ -446,8 +446,9 @@ jobs:
# NOTE: The latest and the lowest supported Pythons are prioritized
# NOTE: to improve the responsiveness. It's nice to see the most
# NOTE: important results first.
- '3.11'
- '3.12'
- 3.6
- '3.11'
- '3.10'
- 3.9
- 3.8

View File

@ -292,9 +292,7 @@ class HttpProtocolHandler(BaseTcpServerHandler[HttpClientConnection]):
return True
# Discover which HTTP handler plugin is capable of
# handling the current incoming request
klass = self._discover_plugin_klass(
self.request.http_handler_protocol,
)
klass = self._discover_plugin_klass(self.request.http_handler_protocol)
if klass is None:
# No matching protocol class found.
# Return bad request response and

View File

@ -59,19 +59,6 @@ def test_on_client_connection_called_on_teardown(mocker: MockerFixture) -> None:
assert _conn.closed
def mock_selector_for_client_read(self: Any) -> None:
self.mock_selector.return_value.select.return_value = [
(
selectors.SelectorKey(
fileobj=self._conn.fileno(),
fd=self._conn.fileno(),
events=selectors.EVENT_READ,
data=None,
),
selectors.EVENT_READ,
),
]
# @mock.patch('socket.fromfd')
# def test_on_client_connection_called_on_teardown(
# self, mock_fromfd: mock.Mock,
@ -171,16 +158,40 @@ class TestWebServerPluginWithPacFilePlugin(Assertions):
b'GET / HTTP/1.1',
CRLF,
])
mock_selector_for_client_read(self)
self.mock_selector.return_value.select.side_effect = [
[
(
selectors.SelectorKey(
fileobj=self._conn.fileno(),
fd=self._conn.fileno(),
events=selectors.EVENT_READ,
data=None,
),
selectors.EVENT_READ,
),
],
[
(
selectors.SelectorKey(
fileobj=self._conn.fileno(),
fd=self._conn.fileno(),
events=selectors.EVENT_WRITE,
data=None,
),
selectors.EVENT_WRITE,
),
],
]
@pytest.mark.asyncio # type: ignore[misc]
async def test_pac_file_served_from_disk(self) -> None:
await self.protocol_handler._run_once()
await self.protocol_handler._run_once()
self.assertEqual(
self.protocol_handler.request.state,
httpParserStates.COMPLETE,
)
self._conn.send.called_once_with(
self._conn.send.assert_called_once_with(
build_http_response(
200,
reason=b'OK',

View File

@ -1,5 +1,5 @@
[tox]
envlist = py36,py37,py38,py39,py310,py311
envlist = py36,py37,py38,py39,py310,py311,py312
isolated_build = true
minversion = 3.21.0