mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 06:24:18 +02:00
Use fresh FakeServer per test to prevent shared state issues
Docket stores a shared FakeServer as a class attribute (_memory_server). When many tests run in parallel, shared state can cause issues on Windows. Add autouse fixture to reset the shared server before each test. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
55297a06a3
commit
c02c73f556
1 changed files with 21 additions and 0 deletions
|
|
@ -25,6 +25,27 @@ _monitor_strikes_patch = patch(
|
|||
_monitor_strikes_patch.start()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def fresh_fakeredis_server():
|
||||
"""Give each test a fresh FakeServer instead of sharing one.
|
||||
|
||||
Docket stores a shared FakeServer as a class attribute (_memory_server).
|
||||
This can cause issues when many tests run in parallel on Windows.
|
||||
Reset it before each test to ensure isolation.
|
||||
"""
|
||||
from docket import Docket
|
||||
|
||||
# Clear the shared server so each test gets a fresh one
|
||||
if hasattr(Docket, "_memory_server"):
|
||||
delattr(Docket, "_memory_server")
|
||||
|
||||
yield
|
||||
|
||||
# Clean up after test
|
||||
if hasattr(Docket, "_memory_server"):
|
||||
delattr(Docket, "_memory_server")
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(items):
|
||||
"""Automatically mark tests in integration_tests folder with 'integration' marker."""
|
||||
for item in items:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue