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)