Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Python 3.12 #1444

Merged
merged 5 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading