218
218
elif isinstance(err[1], UnavailableFeature):
219
219
return self.addNotSupported(test, err[1].args[0])
221
self._cleanupLogFile(test)
222
221
unittest.TestResult.addError(self, test, err)
223
222
self.error_count += 1
224
223
self.report_error(test, err)
225
224
if self.stop_early:
226
self._cleanupLogFile(test)
228
228
def addFailure(self, test, err):
229
229
"""Tell result that test failed.
235
235
if isinstance(err[1], KnownFailure):
236
236
return self._addKnownFailure(test, err)
238
self._cleanupLogFile(test)
239
238
unittest.TestResult.addFailure(self, test, err)
240
239
self.failure_count += 1
241
240
self.report_failure(test, err)
242
241
if self.stop_early:
243
self._cleanupLogFile(test)
245
245
def addSuccess(self, test):
246
246
"""Tell result that test completed successfully.
925
925
list(func(*args, **kwargs))
929
929
if getattr(excClass,'__name__', None) is not None:
930
930
excName = excClass.__name__
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'
2758
2774
'bzrlib.tests.test_revisionspec',
2759
2775
'bzrlib.tests.test_revisiontree',
2760
2776
'bzrlib.tests.test_rio',
2777
'bzrlib.tests.test_rules',
2761
2778
'bzrlib.tests.test_sampler',
2762
2779
'bzrlib.tests.test_selftest',
2763
2780
'bzrlib.tests.test_setup',
2795
2812
'bzrlib.tests.test_versionedfile',
2796
2813
'bzrlib.tests.test_version',
2797
2814
'bzrlib.tests.test_version_info',
2815
'bzrlib.tests.test__walkdirs_win32',
2798
2816
'bzrlib.tests.test_weave',
2799
2817
'bzrlib.tests.test_whitebox',
2800
2818
'bzrlib.tests.test_win32utils',
3073
3091
def _probe(self):
3093
# Check for character combinations unlikely to be covered by any
3094
# single non-unicode encoding. We use the characters
3095
# - greek small letter alpha (U+03B1) and
3096
# - braille pattern dots-123456 (U+283F).
3097
os.stat(u'\u03b1\u283f')
3076
3098
except UnicodeEncodeError:
3078
3100
except (IOError, OSError):
3169
3191
FTPServerFeature = _FTPServerFeature()
3194
class _UnicodeFilename(Feature):
3195
"""Does the filesystem support Unicode filenames?"""
3200
except UnicodeEncodeError:
3202
except (IOError, OSError):
3203
# The filesystem allows the Unicode filename but the file doesn't
3207
# The filesystem allows the Unicode filename and the file exists,
3211
UnicodeFilename = _UnicodeFilename()
3214
class _UTF8Filesystem(Feature):
3215
"""Is the filesystem UTF-8?"""
3218
if osutils._fs_enc.upper() in ('UTF-8', 'UTF8'):
3222
UTF8Filesystem = _UTF8Filesystem()
3172
3225
class _CaseInsensitiveFilesystemFeature(Feature):
3173
3226
"""Check if underlined filesystem is case-insensitive
3174
3227
(e.g. on Windows, Cygwin, MacOS)