~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/TestUtil.py

Revert out everything that doesn't deal with exc_info changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import sys
20
20
import logging
21
21
import unittest
22
 
import weakref
23
22
 
24
23
from bzrlib import pyutils
25
24
 
83
82
        tests = list(self)
84
83
        tests.reverse()
85
84
        self._tests = []
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
89
 
        if stream is None:
90
 
            stream = result.decorated._stream
91
 
        stored_count = 0
92
 
        from bzrlib.tests import selftest_debug_flags
93
 
        notify = "collection" in selftest_debug_flags
94
85
        while tests:
95
86
            if result.shouldStop:
96
87
                self._tests = reversed(tests)
97
88
                break
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)
107
90
        return result
108
91
 
109
92
 
110
 
def _run_and_collect_case(case, res):
111
 
    """Run test case against result and use weakref to drop the refcount"""
112
 
    case.run(res)
113
 
    return weakref.ref(case)
114
 
 
115
 
 
116
93
class TestLoader(unittest.TestLoader):
117
94
    """Custom TestLoader to extend the stock python one."""
118
95