Apply suggestions from code review of branch Windows-Testing
Co-authored-by: Richard Bowman <richard.bowman@cantab.net>
This commit is contained in:
parent
d6b00ef1bb
commit
a15458c02d
1 changed files with 3 additions and 5 deletions
|
|
@ -59,14 +59,12 @@ def _git(command: str) -> str:
|
||||||
def temp_dir():
|
def temp_dir():
|
||||||
"""Return the path of a temporary directory (set as working dir)."""
|
"""Return the path of a temporary directory (set as working dir)."""
|
||||||
working_dir = os.getcwd()
|
working_dir = os.getcwd()
|
||||||
try:
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
|
try:
|
||||||
os.chdir(tmpdir)
|
os.chdir(tmpdir)
|
||||||
yield tmpdir
|
yield tmpdir
|
||||||
# Change back to working dir before closing context manager or Windows will error
|
|
||||||
os.chdir(working_dir)
|
|
||||||
finally:
|
finally:
|
||||||
# Ensure changed to working dir
|
# Change back to working dir before closing context manager or Windows will error
|
||||||
os.chdir(working_dir)
|
os.chdir(working_dir)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue