Skip to content

Commit

Permalink
Always cleanup temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
tylern4 committed Aug 28, 2024
1 parent f25bfac commit ce73b91
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,14 @@ def fake_key_file(tmp_path_factory):
"""
)
key_path.chmod(0o100600)
yield key_path
# make sure to cleanup the test since we put a file in ~/.sfapi_test
temp_path = Path().home() / ".sfapi_test1"
if temp_path.exists():
(temp_path / "key.pem").unlink(missing_ok=True)
temp_path.rmdir()
try:
yield key_path
finally:
# make sure to cleanup the test since we put a file in ~/.sfapi_test
temp_path = Path().home() / ".sfapi_test1"
if temp_path.exists():
(temp_path / "key.pem").unlink(missing_ok=True)
temp_path.rmdir()


@pytest.fixture
Expand All @@ -207,9 +209,11 @@ def empty_key_file(tmp_path_factory):
# Makes an empty key
key_path.write_text("")
key_path.chmod(0o100600)
yield key_path
# make sure to cleanup the test since we put a file in ~/.sfapi_test
temp_path = Path().home() / ".sfapi_test2"
if temp_path.exists():
(temp_path / "nokey.pem").unlink(missing_ok=True)
temp_path.rmdir()
try:
yield key_path
finally:
# make sure to cleanup the test since we put a file in ~/.sfapi_test
temp_path = Path().home() / ".sfapi_test2"
if temp_path.exists():
(temp_path / "nokey.pem").unlink(missing_ok=True)
temp_path.rmdir()

0 comments on commit ce73b91

Please sign in to comment.