Skip to content

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

Stop deploy tests from spawning PowerShell on every state access (#5874)

nate nowack623590a94d15
diff --git a/tests/cli/deploy/conftest.py b/tests/cli/deploy/conftest.py
new file mode 100644
index 000000000..09dd1a806
--- /dev/null
+++ b/tests/cli/deploy/conftest.py
@@ -0,0 +1,27 @@
+from __future__ import annotations
+
+import pytest
+
+
[email protected](autouse=True)
+def skip_windows_acl_subprocess(
+ request: pytest.FixtureRequest, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """Keep deploy tests from launching PowerShell for every state access.
+
+ On Windows each read or write of CLI state restricts its ACL through a
+ fresh `powershell.exe`, so a single login test spawns a dozen of them. On
+ contended CI runners that pushes ordinary tests past pytest-timeout, whose
+ Windows thread method kills the whole xdist worker. Tests that exercise
+ the real ACL request `real_windows_acl` instead.
+ """
+ if "real_windows_acl" in request.fixturenames:
+ return
+ monkeypatch.setattr(
+ "fastmcp.cli.deploy.state._restrict_windows_access", lambda path: None
+ )
+
+
+def real_windows_acl() -> None:
+ """Opt out of `skip_windows_acl_subprocess` and run the real PowerShell ACL."""
diff --git a/tests/cli/deploy/test_credentials.py b/tests/cli/deploy/test_credentials.py
index c508be028..a83994eec 100644
--- a/tests/cli/deploy/test_credentials.py
+++ b/tests/cli/deploy/test_credentials.py
@@ -271,7 +271,12 @@ def test_windows_acl_replaces_the_existing_access_list(
@pytest.mark.skipif(os.name != "nt", reason="Windows ACL inspection")
-def test_windows_credential_state_allows_only_the_current_user(tmp_path: Path) -> None:
+# Several cold PowerShell launches; under a contended runner they can outlast
+# the default timeout, which on Windows kills the xdist worker.
+def test_windows_credential_state_allows_only_the_current_user(
+ tmp_path: Path, real_windows_acl: None
+) -> None:
state_directory = tmp_path / "cli"
store = CredentialStore(state_directory)
store.save("fmcp_secret")