2041
2041
self.log("actually: %r" % contents)
2042
2042
self.fail("contents of %s not as expected" % filename)
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:]
2051
name_prefix = re.sub('[/]', '_', self.id())
2044
2054
def makeAndChdirToTestDir(self):
2045
2055
"""See TestCaseWithMemoryTransport.makeAndChdirToTestDir().
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.
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())
2062
for i in range(100):
2063
if os.path.exists(name):
2064
name = name_prefix + '_' + str(i)
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'