Apply suggestions from code review of branch Windows-Testing

Co-authored-by: Richard Bowman <richard.bowman@cantab.net>
This commit is contained in:
Julian Stirling 2026-01-12 21:40:58 +00:00
parent d6b00ef1bb
commit a15458c02d

View file

@ -59,15 +59,13 @@ def _git(command: str) -> str:
def temp_dir():
"""Return the path of a temporary directory (set as working dir)."""
working_dir = os.getcwd()
try:
with tempfile.TemporaryDirectory() as tmpdir:
with tempfile.TemporaryDirectory() as tmpdir:
try:
os.chdir(tmpdir)
yield tmpdir
finally:
# Change back to working dir before closing context manager or Windows will error
os.chdir(working_dir)
finally:
# Ensure changed to working dir
os.chdir(working_dir)
@pytest.fixture