161
161
class ExtendedTestResult(unittest._TextTestResult):
162
162
"""Accepts, reports and accumulates the results of running tests.
164
Compared to this unittest version this class adds support for
164
Compared to the unittest version this class adds support for
165
165
profiling, benchmarking, stopping as soon as a test fails, and
166
166
skipping tests. There are further-specialized subclasses for
167
167
different types of display.
342
342
except KeyboardInterrupt:
345
self.addError(test, test.__exc_info())
345
self.addError(test, test._exc_info())
347
347
# seems best to treat this as success from point-of-view of unittest
348
348
# -- it actually does nothing so it barely matters :)
1835
1835
base = self.get_vfs_only_server().get_url()
1836
1836
return self._adjust_url(base, relpath)
1838
def _create_safety_net(self):
1839
"""Make a fake bzr directory.
1841
This prevents any tests propagating up onto the TEST_ROOT directory's
1844
root = TestCaseWithMemoryTransport.TEST_ROOT
1845
bzrdir.BzrDir.create_standalone_workingtree(root)
1847
def _check_safety_net(self):
1848
"""Check that the safety .bzr directory have not been touched.
1850
_make_test_root have created a .bzr directory to prevent tests from
1851
propagating. This method ensures than a test did not leaked.
1853
root = TestCaseWithMemoryTransport.TEST_ROOT
1854
wt = workingtree.WorkingTree.open(root)
1855
last_rev = wt.last_revision()
1856
if last_rev != 'null:':
1857
# The current test have modified the /bzr directory, we need to
1858
# recreate a new one or all the followng tests will fail.
1859
# If you need to inspect its content uncomment the following line
1860
# import pdb; pdb.set_trace()
1861
_rmtree_temp_dir(root + '/.bzr')
1862
self._create_safety_net()
1863
raise AssertionError('%s/.bzr should not be modified' % root)
1838
1865
def _make_test_root(self):
1839
if TestCaseWithMemoryTransport.TEST_ROOT is not None:
1841
root = osutils.mkdtemp(prefix='testbzr-', suffix='.tmp')
1842
TestCaseWithMemoryTransport.TEST_ROOT = root
1844
# make a fake bzr directory there to prevent any tests propagating
1845
# up onto the source directory's real branch
1846
bzrdir.BzrDir.create_standalone_workingtree(root)
1848
# The same directory is used by all tests, and we're not specifically
1849
# told when all tests are finished. This will do.
1850
atexit.register(_rmtree_temp_dir, root)
1866
if TestCaseWithMemoryTransport.TEST_ROOT is None:
1867
root = osutils.mkdtemp(prefix='testbzr-', suffix='.tmp')
1868
TestCaseWithMemoryTransport.TEST_ROOT = root
1870
self._create_safety_net()
1872
# The same directory is used by all tests, and we're not
1873
# specifically told when all tests are finished. This will do.
1874
atexit.register(_rmtree_temp_dir, root)
1876
self.addCleanup(self._check_safety_net)
1852
1878
def makeAndChdirToTestDir(self):
1853
1879
"""Create a temporary directories for this one test.