/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/__init__.py

  • Committer: Martin Pool
  • Date: 2007-05-13 07:05:24 UTC
  • mto: This revision was merged to the branch mainline in revision 2530.
  • Revision ID: mbp@sourcefrog.net-20070513070524-l5v00s0uzue6ssha
TestCaseInTempDir takes responsibility for cleaning up its own test dir

Show diffs side-by-side

added added

removed removed

Lines of Context:
1859
1859
    All test cases create their own directory within that.  If the
1860
1860
    tests complete successfully, the directory is removed.
1861
1861
 
1862
 
    InTempDir is an old alias for FunctionalTestCase.
 
1862
    :ivar test_base_dir: The path of the top-level directory for this 
 
1863
    test, which contains a home directory and a work directory.
 
1864
 
 
1865
    :ivar test_home_dir: An initially empty directory under test_base_dir
 
1866
    which is used as $HOME for this test.
 
1867
 
 
1868
    :ivar test_dir: A directory under test_base_dir used as the current
 
1869
    directory when the test proper is run.
1863
1870
    """
1864
1871
 
1865
1872
    OVERRIDE_PYTHON = 'python'
1905
1912
                    os.mkdir(candidate_dir)
1906
1913
                    break
1907
1914
        # now create test and home directories within this dir
1908
 
        self.test_home_dir = candidate_dir + '/home'
 
1915
        self.test_base_dir = candidate_dir
 
1916
        self.test_home_dir = self.test_base_dir + '/home'
1909
1917
        os.mkdir(self.test_home_dir)
1910
 
        self.test_dir = candidate_dir + '/work'
 
1918
        self.test_dir = self.test_base_dir + '/work'
1911
1919
        os.mkdir(self.test_dir)
1912
1920
        os.chdir(self.test_dir)
1913
1921
        # put name of test inside
1914
 
        f = file(candidate_dir + '/name', 'w')
 
1922
        f = file(self.test_base_dir + '/name', 'w')
1915
1923
        try:
1916
1924
            f.write(self.id())
1917
1925
        finally:
1918
1926
            f.close()
 
1927
        self.addCleanup(self.deleteTestDir)
 
1928
 
 
1929
    def deleteTestDir(self):
 
1930
        mutter("delete %s" % self.test_base_dir)
 
1931
        _rmtree_temp_dir(self.test_base_dir)
1919
1932
 
1920
1933
    def build_tree(self, shape, line_endings='binary', transport=None):
1921
1934
        """Build a test tree according to a pattern.