Skip to content

Keep the CLI socket policy active outside each test - #558

Open
Gabrieljr42 wants to merge 2 commits into
miketheman:mainfrom
Gabrieljr42:fix/539-session-socket-baseline
Open

Gabrieljr42 wants to merge 2 commits into
miketheman:mainfrom
Gabrieljr42:fix/539-session-socket-baseline

Conversation

@Gabrieljr42

Copy link
Copy Markdown

Fixes #539.

The CLI socket policy is now installed before test-module collection and restored after each test's teardown. An enable_socket marker or fixture no longer leaves sockets open for later tests or pytest_sessionfinish. CLI allow-lists and Unix-socket exceptions also apply outside individual tests.

The regression tests cover imports, session finish, per-test overrides, fixture ordering and allow-lists. The lifecycle tests fail on the original source. The README documents the remaining gaps for initial conftest.py imports and atexit handlers.

I ran the full suite on Python 3.12: 125 passed. All configured pre-commit hooks and uv run mypy src pass. Mutation testing kills all 268 mutants after explicitly rerunning the ten cached survivors with the added coverage.

Related: #557.

Restore the session baseline after teardown and cover collection, sessionfinish, CLI allow-lists, and fixture precedence.

Fixes miketheman#539

Signed-off-by: Gabrieljr42 <gabrieljunior42566@gmail.com>
@codspeed

codspeed Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 24.18%

1 warning

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 11 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_bench_host_from_address 19.8 µs 15.9 µs +24.18%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Gabrieljr42:fix/539-session-socket-baseline (9e1f1ee) with main (6fcf0d2)

Open in CodSpeed

Signed-off-by: Gabrieljr42 <gabrieljunior42566@gmail.com>

This branch has not been deployed

No deployments
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.

--disable-socket only covers each test's setup-to-call window: import/collection time, pytest_sessionfinish and atexit handlers still reach the network

1 participant