Skip to content

Commit a711387

Browse files
Merge pull request #482 from martin-belanger/fix-unit-tests
tests: fix failing tests
2 parents a8f3a3a + c813dcf commit a711387

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

test/test-config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,13 @@ def setUpClass(cls):
343343

344344
@classmethod
345345
def tearDownClass(cls):
346+
# IMPORTANT: reset the SysConf singleton to an empty config BEFORE
347+
# deleting the temp file. SysConf caches _config in memory; simply
348+
# deleting the file leaves the 224-char NQN in the cache. When pytest
349+
# runs all test files in one process, trid.TID.__init__ unconditionally
350+
# evaluates sysconf.hostnqn (as the default arg to dict.get), so every
351+
# TID construction in later test files would hit sys.exit.
352+
conf.SysConf().set_conf_file('/dev/null')
346353
if os.path.exists(cls.FNAME):
347354
os.remove(cls.FNAME)
348355

0 commit comments

Comments
 (0)