Skip to content

Commit

Permalink
[FIX] Recover global state after test_util.py (#5824)
Browse files Browse the repository at this point in the history
In test_util.py, a program exit is simulated to test
that the error throwing behaviour is accurate.
Unforunately, this also deletes necessary global state
and so all subsequent tests that run and use tempdir
throw the same error.

This patch is a simple fix to restore the global state
at the end of the test.

Change-Id: I62fef46167e47f6af43271e2ce1db30f54857647
  • Loading branch information
mbaret authored Jun 19, 2020
1 parent 64766c2 commit c890573
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/python/contrib/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_tempdir():
assert os.path.exists(temp_dir.temp_dir)

old_debug_mode = util.TempDirectory._KEEP_FOR_DEBUG
old_tempdirs = util.TempDirectory.TEMPDIRS
try:
for temp_dir_number in range(0, 3):
with util.TempDirectory.set_keep_for_debug():
Expand Down Expand Up @@ -80,6 +81,7 @@ def test_tempdir():

finally:
util.TempDirectory.DEBUG_MODE = old_debug_mode
util.TempDirectory.TEMPDIRS = old_tempdirs


if __name__ == '__main__':
Expand Down

0 comments on commit c890573

Please sign in to comment.