From d5eb60cb413f2aba1d9dc2b08d53ac14dbc8f0fa Mon Sep 17 00:00:00 2001 From: anti Date: Tue, 14 Apr 2026 17:29:02 -0400 Subject: [PATCH] fix: env leak from live tests caused test_failed_mutation_returns_404 to fail The live test modules set DECNET_CONTRACT_TEST=true at module level, which persisted across xdist workers and caused the mutate endpoint to short-circuit before the mock was reached. Clear the env var in affected tests with monkeypatch.delenv. --- tests/api/fleet/test_mutate_decky.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/api/fleet/test_mutate_decky.py b/tests/api/fleet/test_mutate_decky.py index c8cbb97..d5d529a 100644 --- a/tests/api/fleet/test_mutate_decky.py +++ b/tests/api/fleet/test_mutate_decky.py @@ -14,7 +14,8 @@ class TestMutateDecky: assert resp.status_code == 401 @pytest.mark.asyncio - async def test_successful_mutation(self, client: httpx.AsyncClient, auth_token: str): + async def test_successful_mutation(self, client: httpx.AsyncClient, auth_token: str, monkeypatch: pytest.MonkeyPatch): + monkeypatch.delenv("DECNET_CONTRACT_TEST", raising=False) with patch("decnet.web.router.fleet.api_mutate_decky.mutate_decky", return_value=True): resp = await client.post( "/api/v1/deckies/decky-01/mutate", @@ -24,7 +25,8 @@ class TestMutateDecky: assert "Successfully mutated" in resp.json()["message"] @pytest.mark.asyncio - async def test_failed_mutation_returns_404(self, client: httpx.AsyncClient, auth_token: str): + async def test_failed_mutation_returns_404(self, client: httpx.AsyncClient, auth_token: str, monkeypatch: pytest.MonkeyPatch): + monkeypatch.delenv("DECNET_CONTRACT_TEST", raising=False) with patch("decnet.web.router.fleet.api_mutate_decky.mutate_decky", return_value=False): resp = await client.post( "/api/v1/deckies/decky-01/mutate",