Skip to content

Commit

Permalink
Support for Python 3.12 (#1444)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
abhinavsingh and pre-commit-ci[bot] authored Aug 10, 2024
1 parent 201d02c commit 1e4e87d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions proxy/http/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,7 @@ def _parse_first_request(self, data: memoryview) -> bool:
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
Expand Down
41 changes: 26 additions & 15 deletions tests/http/web/test_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -171,16 +158,40 @@ def _setUp(self, request: Any, mocker: MockerFixture) -> None:
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',
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 1e4e87d

Please sign in to comment.