93
93
DocTestMatches(u"...a test message\n", doctest.ELLIPSIS))
96
class TestUnicodeFilename(tests.TestCase):
98
def test_probe_passes(self):
99
"""UnicodeFilename._probe passes."""
100
# We can't test much more than that because the behaviour depends
102
tests.UnicodeFilename._probe()
105
96
class TestTreeShape(tests.TestCaseInTempDir):
107
98
def test_unicode_paths(self):
108
self.requireFeature(tests.UnicodeFilename)
99
self.requireFeature(features.UnicodeFilenameFeature)
110
101
filename = u'hell\u00d8'
111
102
self.build_tree_contents([(filename, 'contents of hello')])
897
888
self._call = test, feature
898
889
result = InstrumentedTestResult(None, None, None, None)
899
890
test = SampleTestCase('_test_pass')
900
feature = tests.Feature()
891
feature = features.Feature()
901
892
result.startTest(test)
902
893
result.addNotSupported(test, feature)
903
894
# it should invoke 'report_unsupported'.
941
932
def addNotSupported(self, test, feature):
942
933
self._call = test, feature
943
934
result = InstrumentedTestResult(None, None, None, None)
944
feature = tests.Feature()
935
feature = features.Feature()
945
936
class Test(tests.TestCase):
946
937
def test_function(self):
947
938
raise tests.UnavailableFeature(feature)
1192
1174
def test_unsupported_features_listed(self):
1193
1175
"""When unsupported features are encountered they are detailed."""
1194
class Feature1(tests.Feature):
1176
class Feature1(features.Feature):
1195
1177
def _probe(self): return False
1196
class Feature2(tests.Feature):
1178
class Feature2(features.Feature):
1197
1179
def _probe(self): return False
1198
1180
# create sample tests
1199
1181
test1 = SampleTestCase('_test_pass')
1513
1495
def test_requireFeature_available(self):
1514
1496
"""self.requireFeature(available) is a no-op."""
1515
class Available(tests.Feature):
1497
class Available(features.Feature):
1516
1498
def _probe(self):return True
1517
1499
feature = Available()
1518
1500
self.requireFeature(feature)
1520
1502
def test_requireFeature_unavailable(self):
1521
1503
"""self.requireFeature(unavailable) raises UnavailableFeature."""
1522
class Unavailable(tests.Feature):
1504
class Unavailable(features.Feature):
1523
1505
def _probe(self):return False
1524
1506
feature = Unavailable()
1525
1507
self.assertRaises(tests.UnavailableFeature,
2607
2589
self.assertEqual('bzr: interrupted\n', result[1])
2610
class TestFeature(tests.TestCase):
2612
def test_caching(self):
2613
"""Feature._probe is called by the feature at most once."""
2614
class InstrumentedFeature(tests.Feature):
2616
super(InstrumentedFeature, self).__init__()
2619
self.calls.append('_probe')
2621
feature = InstrumentedFeature()
2623
self.assertEqual(['_probe'], feature.calls)
2625
self.assertEqual(['_probe'], feature.calls)
2627
def test_named_str(self):
2628
"""Feature.__str__ should thunk to feature_name()."""
2629
class NamedFeature(tests.Feature):
2630
def feature_name(self):
2632
feature = NamedFeature()
2633
self.assertEqual('symlinks', str(feature))
2635
def test_default_str(self):
2636
"""Feature.__str__ should default to __class__.__name__."""
2637
class NamedFeature(tests.Feature):
2639
feature = NamedFeature()
2640
self.assertEqual('NamedFeature', str(feature))
2643
class TestUnavailableFeature(tests.TestCase):
2645
def test_access_feature(self):
2646
feature = tests.Feature()
2647
exception = tests.UnavailableFeature(feature)
2648
self.assertIs(feature, exception.args[0])
2651
simple_thunk_feature = tests._CompatabilityThunkFeature(
2652
deprecated_in((2, 1, 0)),
2653
'bzrlib.tests.test_selftest',
2654
'simple_thunk_feature','UnicodeFilename',
2655
replacement_module='bzrlib.tests'
2658
class Test_CompatibilityFeature(tests.TestCase):
2660
def test_does_thunk(self):
2661
res = self.callDeprecated(
2662
['bzrlib.tests.test_selftest.simple_thunk_feature was deprecated'
2663
' in version 2.1.0. Use bzrlib.tests.UnicodeFilename instead.'],
2664
simple_thunk_feature.available)
2665
self.assertEqual(tests.UnicodeFilename.available(), res)
2668
class TestModuleAvailableFeature(tests.TestCase):
2670
def test_available_module(self):
2671
feature = tests.ModuleAvailableFeature('bzrlib.tests')
2672
self.assertEqual('bzrlib.tests', feature.module_name)
2673
self.assertEqual('bzrlib.tests', str(feature))
2674
self.assertTrue(feature.available())
2675
self.assertIs(tests, feature.module)
2677
def test_unavailable_module(self):
2678
feature = tests.ModuleAvailableFeature('bzrlib.no_such_module_exists')
2679
self.assertEqual('bzrlib.no_such_module_exists', str(feature))
2680
self.assertFalse(feature.available())
2681
self.assertIs(None, feature.module)
2684
2592
class TestSelftestFiltering(tests.TestCase):
2686
2594
def setUp(self):