613
613
self.assertEqual(format.repository_format.__class__,
614
614
tree.branch.repository._format.__class__)
616
def test_safety_net(self):
617
"""No test should modify the safety .bzr directory.
619
We just test that the _check_safety_net private method raises
620
AssertionError, it's easier than building a test suite with the same
623
# Oops, a commit in the current directory (i.e. without local .bzr
624
# directory) will crawl up the hierarchy to find a .bzr directory.
625
self.run_bzr(['commit', '-mfoo', '--unchanged'])
626
# But we have a safety net in place.
627
self.assertRaises(AssertionError, self._check_safety_net)
617
630
class TestTestCaseWithTransport(TestCaseWithTransport):
618
631
"""Tests for the convenience functions TestCaseWithTransport introduces."""
1659
1672
self.check_inventory_shape(tree.inventory, files)
1677
class TestBlackboxSupport(TestCase):
1678
"""Tests for testsuite blackbox features."""
1680
def test_run_bzr_failure_not_caught(self):
1681
# When we run bzr in blackbox mode, we want any unexpected errors to
1682
# propagate up to the test suite so that it can show the error in the
1683
# usual way, and we won't get a double traceback.
1684
e = self.assertRaises(
1686
self.run_bzr, ['assert-fail'])
1687
# make sure we got the real thing, not an error from somewhere else in
1688
# the test framework
1689
self.assertEquals('always fails', str(e))
1690
# check that there's no traceback in the test log
1691
self.assertNotContainsRe(self._get_log(keep_log_file=True),
1694
def test_run_bzr_user_error_caught(self):
1695
# Running bzr in blackbox mode, normal/expected/user errors should be
1696
# caught in the regular way and turned into an error message plus exit
1698
out, err = self.run_bzr(["log", "/nonexistantpath"], retcode=3)
1699
self.assertEqual(out, '')
1700
self.assertEqual(err, 'bzr: ERROR: Not a branch: "/nonexistantpath/".\n')