Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Fix Windows test timeouts from SQLite locking (#2368)

Jeremiah Lowinc6a9b3df2222
diff --git a/tests/conftest.py b/tests/conftest.py
index 0d7e7c090..22487f97e 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,9 +1,12 @@
import socket
from collections.abc import Callable
+from pathlib import Path
from typing import Any
import pytest
+from fastmcp.utilities.tests import temporary_settings
+
def pytest_collection_modifyitems(items):
"""Automatically mark tests in integration_tests folder with 'integration' marker."""
@@ -21,6 +24,20 @@ def import_rich_rule():
yield
[email protected](autouse=True)
+def isolate_settings_home(tmp_path: Path):
+ """Ensure each test uses an isolated settings.home directory.
+
+ This prevents SQLite database locking issues on Windows when multiple
+ tests share the same DiskStore directory in settings.home / "oauth-proxy".
+ """
+ test_home = tmp_path / "fastmcp-test-home"
+ test_home.mkdir(exist_ok=True)
+
+ with temporary_settings(home=test_home):
+ yield
+
+
def get_fn_name(fn: Callable[..., Any]) -> str:
return fn.__name__ # ty: ignore[unresolved-attribute]