86
stream = getattr(result, "stream", None)
87
# With subunit, not only is stream underscored, but the actual result
88
# object is hidden inside a wrapper decorator, get out the real stream
90
stream = result.decorated._stream
92
from bzrlib.tests import selftest_debug_flags
93
notify = "collection" in selftest_debug_flags
95
86
if result.shouldStop:
96
87
self._tests = reversed(tests)
98
case = _run_and_collect_case(tests.pop(), result)()
99
new_stored_count = getattr(result, "_count_stored_tests", int)()
100
if case is not None and isinstance(case, unittest.TestCase):
101
if stored_count == new_stored_count and notify:
102
# Testcase didn't fail, but somehow is still alive
103
stream.write("Uncollected test case: %s\n" % (case.id(),))
104
# Zombie the testcase but leave a working stub id method
105
case.__dict__ = {"id": lambda _id=case.id(): _id}
106
stored_count = new_stored_count
89
tests.pop().run(result)
110
def _run_and_collect_case(case, res):
111
"""Run test case against result and use weakref to drop the refcount"""
113
return weakref.ref(case)
116
93
class TestLoader(unittest.TestLoader):
117
94
"""Custom TestLoader to extend the stock python one."""