~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Vincent Ladeuil
  • Date: 2007-10-02 11:21:44 UTC
  • mfrom: (2817.5.1 scratch)
  • mto: (2885.2.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 2887.
  • Revision ID: v.ladeuil+lp@free.fr-20071002112144-et1xbsdbof2y9urw
Fix #147986 by monitoring a safety .bzr directory.

* bzrlib/tests/test_selftest.py:
(TestTestCaseWithMemoryTransport.test_safety_net): Accompanying
test.

* bzrlib/tests/__init__.py:
(ExtendedTestResult): Old error, never detected before.
(TestCaseWithMemoryTransport._create_safety_net): New method
explicitely creating a safety net to protect higher .bzr
directories from being polluted by tests.
(TestCaseWithMemoryTransport._check_safety_net): New method
checking that a test did not modify the safety net and re-create a
virgin safety net if it has modified it.

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. I's eaiser 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."""