/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

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
564
564
    def test_home_is_not_working(self):
565
565
        self.assertNotEqual(self.test_dir, self.test_home_dir)
566
566
        cwd = osutils.getcwd()
567
 
        self.assertEqual(self.test_dir, cwd)
568
 
        self.assertEqual(self.test_home_dir, os.environ['HOME'])
 
567
        self.assertIsSameRealPath(self.test_dir, cwd)
 
568
        self.assertIsSameRealPath(self.test_home_dir, os.environ['HOME'])
569
569
 
570
570
 
571
571
class TestTestCaseWithMemoryTransport(TestCaseWithMemoryTransport):
579
579
        few tests should need to do that), and having a missing dir as home is
580
580
        an effective way to ensure that this is the case.
581
581
        """
582
 
        self.assertEqual(self.TEST_ROOT + "/MemoryTransportMissingHomeDir",
 
582
        self.assertIsSameRealPath(
 
583
            self.TEST_ROOT + "/MemoryTransportMissingHomeDir",
583
584
            self.test_home_dir)
584
 
        self.assertEqual(self.test_home_dir, os.environ['HOME'])
 
585
        self.assertIsSameRealPath(self.test_home_dir, os.environ['HOME'])
585
586
        
586
587
    def test_cwd_is_TEST_ROOT(self):
587
 
        self.assertEqual(self.test_dir, self.TEST_ROOT)
 
588
        self.assertIsSameRealPath(self.test_dir, self.TEST_ROOT)
588
589
        cwd = osutils.getcwd()
589
 
        self.assertEqual(self.test_dir, cwd)
 
590
        self.assertIsSameRealPath(self.test_dir, cwd)
590
591
 
591
592
    def test_make_branch_and_memory_tree(self):
592
593
        """In TestCaseWithMemoryTransport we should not make the branch on disk.
612
613
        self.assertEqual(format.repository_format.__class__,
613
614
            tree.branch.repository._format.__class__)
614
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
 
615
629
 
616
630
class TestTestCaseWithTransport(TestCaseWithTransport):
617
631
    """Tests for the convenience functions TestCaseWithTransport introduces."""
1658
1672
            self.check_inventory_shape(tree.inventory, files)
1659
1673
        finally:
1660
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')