Skip to content

Commit

Permalink
Assert that the chdir finally always executes
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidHuber-NOAA committed Nov 14, 2024
1 parent da60838 commit 6524b8b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_fsutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ def test_chdir(tmp_path):
with chdir("/a/non-existent/path"):
raise AssertionError("Navigated to a non-existent path")

# Lastly, test that we return to the orignial working directory when there is an error
try:
with chdir(dir_path):
1 / 0
except ZeroDivisionError:
pass

assert os.getcwd() == cwd


def test_rm_p(tmp_path):
"""
Expand Down

0 comments on commit 6524b8b

Please sign in to comment.