Skip to content

tests: start the served fixture on a free port - #40

Merged
tae898 merged 1 commit into
mainfrom
tests/served-free-port
Oct 24, 2026
Merged

tae898 merged 1 commit into
mainfrom
tests/served-free-port

Conversation

@tae898

@tae898 tae898 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #36. PR #28 added the served fixture to tests/test_server_packaging.py after #36 was written, so that fixture still started its server on the default fixed port 2480. test_openapi_json_is_served and test_snappy_compressed_bodies_are_decoded therefore errored with "Unable to listen to a HTTP port in the configured port range 2480 - 2480" whenever anything else on the machine held 2480.

The fixture now passes config={"http_port": free_port()}, the helper #36 added to tests/conftest.py. It was the only server start in tests/ still on a fixed port. test_server.py::test_default_host_is_localhost builds a server without starting it, so it binds nothing and stays as is. test_server_wire_protocols.py already used _free_ports. isort also added the blank line between the third-party and first-party imports in that fixture.

Checked with a dummy listener holding 0.0.0.0:2480, pinned taskset -c 0-3, on the 26.11.1.dev0 cp312 wheel. Before the change tests/test_server_packaging.py gave 4 passed, 2 errors (the two served tests, with the message above). After it gives 6 passed. All the server test files together (test_server.py, test_server_packaging.py, test_server_patterns.py, test_server_http_endpoints.py, test_server_wire_protocols.py) give 32 passed with 2480 held. pre-commit is clean.

🤖 Generated with Claude Code

PR #28 added the served fixture in test_server_packaging.py after #36 was written, so it still started its server on the default fixed port 2480 and errored whenever anything else held that port. It now passes config={"http_port": free_port()} like every other server test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tae898
tae898 merged commit 61a66ac into main Oct 24, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant