diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index 50d0549..3b432d1 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -11,9 +11,3 @@ 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 1970268..9107b1c 100644 --- a/tests/functional/test_token.py +++ b/tests/functional/test_token.py @@ -1,3 +1,4 @@ +import shutil import subprocess import helpers_functional as helpers @@ -69,7 +70,9 @@ def test_invalid_repo_token(uv_run, test_dir): assert not (test_dir / "invalid").exists() -def test_bad_token_no_owner(uv_run, fresh_dir): +def test_bad_token_no_owner(uv_run, test_dir): + # An earlier test in this module may have created jubilant. + shutil.rmtree(test_dir / "jubilant", ignore_errors=True) command = [ *uv_run, "gimmegit", @@ -78,7 +81,7 @@ def test_bad_token_no_owner(uv_run, fresh_dir): ] result = subprocess.run( command, - cwd=fresh_dir, + cwd=test_dir, env=helpers.bad_token_env(), capture_output=True, text=True, @@ -93,10 +96,12 @@ def test_bad_token_no_owner(uv_run, fresh_dir): Error: GitHub rejected the token. Has the token expired? """ assert result.stderr == expected_stderr - assert not (fresh_dir / "jubilant").exists() + assert not (test_dir / "jubilant").exists() -def test_bad_token_no_upstream_owner(uv_run, fresh_dir): +def test_bad_token_no_upstream_owner(uv_run, test_dir): + # An earlier test in this module may have created jubilant. + shutil.rmtree(test_dir / "jubilant", ignore_errors=True) command = [ *uv_run, "gimmegit", @@ -105,7 +110,7 @@ def test_bad_token_no_upstream_owner(uv_run, fresh_dir): ] result = subprocess.run( command, - cwd=fresh_dir, + cwd=test_dir, env=helpers.bad_token_env(), capture_output=True, text=True, @@ -120,7 +125,7 @@ def test_bad_token_no_upstream_owner(uv_run, fresh_dir): Error: GitHub rejected the token. Has the token expired? """ assert result.stderr == expected_stderr - assert not (fresh_dir / "jubilant").exists() + assert not (test_dir / "jubilant").exists() @pytest.mark.skipif(helpers.token_unset.condition, reason=helpers.token_unset.reason)