/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: Robert Collins
  • Date: 2008-07-28 06:08:42 UTC
  • mfrom: (3581 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3584.
  • Revision ID: robertc@robertcollins.net-20080728060842-uayjy217i066dvct
MergeĀ .dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2041
2041
            self.log("actually: %r" % contents)
2042
2042
            self.fail("contents of %s not as expected" % filename)
2043
2043
 
 
2044
    def _getTestDirPrefix(self):
 
2045
        # create a directory within the top level test directory
 
2046
        if sys.platform == 'win32':
 
2047
            name_prefix = re.sub('[<>*=+",:;_/\\-]', '_', self.id())
 
2048
            # windows is likely to have path-length limits so use a short name
 
2049
            name_prefix = name_prefix[-30:]
 
2050
        else:
 
2051
            name_prefix = re.sub('[/]', '_', self.id())
 
2052
        return name_prefix
 
2053
 
2044
2054
    def makeAndChdirToTestDir(self):
2045
2055
        """See TestCaseWithMemoryTransport.makeAndChdirToTestDir().
2046
2056
        
2047
2057
        For TestCaseInTempDir we create a temporary directory based on the test
2048
2058
        name and then create two subdirs - test and home under it.
2049
2059
        """
2050
 
        # create a directory within the top level test directory
2051
 
        candidate_dir = osutils.mkdtemp(dir=self.TEST_ROOT)
 
2060
        name_prefix = os.path.join(self.TEST_ROOT, self._getTestDirPrefix())
 
2061
        name = name_prefix
 
2062
        for i in range(100):
 
2063
            if os.path.exists(name):
 
2064
                name = name_prefix + '_' + str(i)
 
2065
            else:
 
2066
                os.mkdir(name)
 
2067
                break
2052
2068
        # now create test and home directories within this dir
2053
 
        self.test_base_dir = candidate_dir
 
2069
        self.test_base_dir = name
2054
2070
        self.test_home_dir = self.test_base_dir + '/home'
2055
2071
        os.mkdir(self.test_home_dir)
2056
2072
        self.test_dir = self.test_base_dir + '/work'