/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Martin Pool
  • Date: 2007-10-10 00:21:57 UTC
  • mfrom: (2900 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2901.
  • Revision ID: mbp@sourcefrog.net-20071010002157-utci0x44m2w47wgd
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
613
613
        self.assertEqual(format.repository_format.__class__,
614
614
            tree.branch.repository._format.__class__)
615
615
 
 
616
    def test_safety_net(self):
 
617
        """No test should modify the safety .bzr directory.
 
618
 
 
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
 
621
        test.
 
622
        """
 
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)
 
628
 
616
629
 
617
630
class TestTestCaseWithTransport(TestCaseWithTransport):
618
631
    """Tests for the convenience functions TestCaseWithTransport introduces."""
1659
1672
            self.check_inventory_shape(tree.inventory, files)
1660
1673
        finally:
1661
1674
            tree.unlock()
 
1675
 
 
1676
 
 
1677
class TestBlackboxSupport(TestCase):
 
1678
    """Tests for testsuite blackbox features."""
 
1679
 
 
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(
 
1685
            AssertionError,
 
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),
 
1692
            r'Traceback')
 
1693
 
 
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
 
1697
        # code.
 
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')