From 79b401ddedb588198d6cb17a217529f3eb5da153 Mon Sep 17 00:00:00 2001 From: Dave Wilding Date: Tue, 27 Oct 2026 07:49:41 -0500 Subject: [PATCH] fix: isolate bad-token tests from the module-wide test dir The bad-token tests assert that nothing is created on disk when the token is rejected. That assertion only holds in a fresh dir, but they shared the module-scoped test_dir fixture with test_forked_repo_token, which clones jubilant/ before they run whenever a GITHUB_TOKEN is set. The full functional tests therefore failed on push to main (though PR runs pass, because they skip the token tests and leave the shared dir empty). Give the bad-token tests a function-scoped fresh_dir fixture so each gets a dir no other test has touched. Restore the "nothing exists" assertion reverted in #207 (its "or empty" relaxation assumed gimmegit itself could create the dir, but a rejected token always exits before cloning starts). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/functional/conftest.py | 6 ++++++ tests/functional/test_token.py | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index 3b432d1..50d0549 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -11,3 +11,9 @@ def uv_run(): @pytest.fixture(scope="module") def test_dir(tmp_path_factory): yield tmp_path_factory.mktemp("functional") + + +@pytest.fixture() +def fresh_dir(tmp_path_factory): + # A dir no other test has touched. Use it in tests that assert nothing is created. + yield tmp_path_factory.mktemp("functional") diff --git a/tests/functional/test_token.py b/tests/functional/test_token.py index b24b148..1970268 100644 --- a/tests/functional/test_token.py +++ b/tests/functional/test_token.py @@ -69,7 +69,7 @@ def test_invalid_repo_token(uv_run, test_dir): assert not (test_dir / "invalid").exists() -def test_bad_token_no_owner(uv_run, test_dir): +def test_bad_token_no_owner(uv_run, fresh_dir): command = [ *uv_run, "gimmegit", @@ -78,7 +78,7 @@ def test_bad_token_no_owner(uv_run, test_dir): ] result = subprocess.run( command, - cwd=test_dir, + cwd=fresh_dir, env=helpers.bad_token_env(), capture_output=True, text=True, @@ -93,10 +93,10 @@ def test_bad_token_no_owner(uv_run, test_dir): Error: GitHub rejected the token. Has the token expired? """ assert result.stderr == expected_stderr - assert not (test_dir / "jubilant").exists() or not any((test_dir / "jubilant").iterdir()) + assert not (fresh_dir / "jubilant").exists() -def test_bad_token_no_upstream_owner(uv_run, test_dir): +def test_bad_token_no_upstream_owner(uv_run, fresh_dir): command = [ *uv_run, "gimmegit", @@ -105,7 +105,7 @@ def test_bad_token_no_upstream_owner(uv_run, test_dir): ] result = subprocess.run( command, - cwd=test_dir, + cwd=fresh_dir, env=helpers.bad_token_env(), capture_output=True, text=True, @@ -120,7 +120,7 @@ def test_bad_token_no_upstream_owner(uv_run, test_dir): Error: GitHub rejected the token. Has the token expired? """ assert result.stderr == expected_stderr - assert not (test_dir / "jubilant").exists() or not any((test_dir / "jubilant").iterdir()) + assert not (fresh_dir / "jubilant").exists() @pytest.mark.skipif(helpers.token_unset.condition, reason=helpers.token_unset.reason)