Browse Source

tests: cleanup tracebacks also for expectedFailure exception

Continuation of 5bc0baea "tests: do not leak objects in object leaks
checking function".
Marek Marczykowski-Górecki 5 years ago
parent
commit
00c0b4c69f
1 changed files with 5 additions and 3 deletions
  1. 5 3
      qubes/tests/__init__.py

+ 5 - 3
qubes/tests/__init__.py

@@ -386,9 +386,11 @@ class QubesTestCase(unittest.TestCase):
         '''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
+        exc_infos = [e for test_case, e in self._outcome.errors
+            if test_case is self]
+        if self._outcome.expectedFailure:
+            exc_infos.append(self._outcome.expectedFailure)
+        for exc_info in exc_infos:
             if exc_info is None:
                 continue
             ex = exc_info[1]