Skip to content

test(session): define the shared config/manager fixtures once in conftest.py - #281

Merged
allen0099 merged 1 commit into
masterfrom
test/session-shared-fixtures-187
Sep 27, 2026
Merged

allen0099 merged 1 commit into
masterfrom
test/session-shared-fixtures-187

Conversation

@allen0099

Copy link
Copy Markdown
Owner

Summary

Closes #187

Part of #123.

tests/session/conftest.py now defines three fixtures, and the five files that had their own copies use them:

  • backend: a MemoryBackend;
  • config: SessionConfig(secret_key="a" * 32);
  • manager: SessionManager(backend, config).

What each file had:

  • test_middleware.py, test_get_session_manager.py and test_starlette_middleware.py: config and manager exactly as above. Both are removed.
  • test_manager.py: the same three fixtures, but its config passed session_ttl=3600, which is SessionConfig's default. All three are removed. Its tests that take both manager and backend still get the same backend instance, because the shared manager is built from the shared backend fixture.
  • test_hardening.py: its config differs (ip_binding=True), so it stays local and overrides the shared one. Its manager was identical and is removed; the shared manager picks up the local config through normal fixture overriding.

No other file under tests/session/ defines these fixture names or takes a backend argument.

Verification

  • Collected tests are unchanged: 1031 before and after.
  • uv run pytest (live servers skipped): 841 passed, 190 skipped.
  • Mutation checks:
    • forcing session_ttl=1 in the shared manager fails 2 session tests, so the shared fixtures are in use;
    • flipping test_hardening.py's local config to ip_binding=False fails 1 hardening test, so the override still reaches the shared manager.
  • ruff check and pre-commit pass.

CHANGELOG

None: test-only.

…test.py

Five session test files each defined their own config and manager
fixtures. They now come from tests/session/conftest.py, together with the
backend fixture test_manager.py used alongside manager. test_hardening.py
keeps its own config (IP binding on), which the shared manager picks up.
@allen0099 allen0099 added the enhancement New feature or request label Sep 27, 2026
@allen0099 allen0099 added this to the 0.3.8 milestone Sep 27, 2026
@allen0099
allen0099 merged commit 2fc7a45 into master Sep 27, 2026
10 checks passed
@allen0099
allen0099 deleted the test/session-shared-fixtures-187 branch September 27, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests: move shared session fixtures to tests/session/conftest.py

1 participant