Skip to content

Commit c890573

Browse files
authored
[FIX] Recover global state after test_util.py (apache#5824)
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
1 parent 64766c2 commit c890573

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tests/python/contrib/test_util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def test_tempdir():
3939
assert os.path.exists(temp_dir.temp_dir)
4040

4141
old_debug_mode = util.TempDirectory._KEEP_FOR_DEBUG
42+
old_tempdirs = util.TempDirectory.TEMPDIRS
4243
try:
4344
for temp_dir_number in range(0, 3):
4445
with util.TempDirectory.set_keep_for_debug():
@@ -80,6 +81,7 @@ def test_tempdir():
8081

8182
finally:
8283
util.TempDirectory.DEBUG_MODE = old_debug_mode
84+
util.TempDirectory.TEMPDIRS = old_tempdirs
8385

8486

8587
if __name__ == '__main__':

0 commit comments

Comments
 (0)