tests: clean local variables from traceback objects
System tests are fragile for any object leaks, especially those holding open files. Instead of wrapping all tests with try/finally removing those local variables (as done in qubes.tests.integ.backup for example), apply generic solution: clean all traceback objects from local variables. Those aren't used to generate text report by either test runner (qubes.tests.run and nose2). If one wants to break into debugger and inspect tracebacks interactively, needs to comment out call to cleanup_traceback.
This commit is contained in:
parent
c102fa3d68
commit
b2cc605f4b
@ -379,8 +379,20 @@ class QubesTestCase(unittest.TestCase):
|
||||
|
||||
self.loop = asyncio.get_event_loop()
|
||||
self.addCleanup(self.cleanup_loop)
|
||||
self.addCleanup(self.cleanup_traceback)
|
||||
self.addCleanup(qubes.ext.pci._cache_get.cache_clear)
|
||||
|
||||
def cleanup_traceback(self):
|
||||
'''Remove local variables reference from tracebacks to allow garbage
|
||||
collector to clean all Qubes*() objects, otherwise file descriptors
|
||||
held by them will leak'''
|
||||
for test_case, exc_info in self._outcome.errors:
|
||||
if test_case is not self:
|
||||
continue
|
||||
if exc_info is None:
|
||||
continue
|
||||
traceback.clear_frames(exc_info[2])
|
||||
|
||||
def cleanup_gc(self):
|
||||
gc.collect()
|
||||
leaked = [obj for obj in gc.get_objects() + gc.garbage
|
||||
|
Loading…
Reference in New Issue
Block a user