92
92
DocTestMatches(u"...a test message\n", doctest.ELLIPSIS))
95
class TestUnicodeFilename(tests.TestCase):
97
def test_probe_passes(self):
98
"""UnicodeFilename._probe passes."""
99
# We can't test much more than that because the behaviour depends
101
tests.UnicodeFilename._probe()
104
95
class TestTreeShape(tests.TestCaseInTempDir):
106
97
def test_unicode_paths(self):
107
self.requireFeature(tests.UnicodeFilename)
98
self.requireFeature(features.UnicodeFilename)
109
100
filename = u'hell\u00d8'
110
101
self.build_tree_contents([(filename, 'contents of hello')])
896
887
self._call = test, feature
897
888
result = InstrumentedTestResult(None, None, None, None)
898
889
test = SampleTestCase('_test_pass')
899
feature = tests.Feature()
890
feature = features.Feature()
900
891
result.startTest(test)
901
892
result.addNotSupported(test, feature)
902
893
# it should invoke 'report_unsupported'.
940
931
def addNotSupported(self, test, feature):
941
932
self._call = test, feature
942
933
result = InstrumentedTestResult(None, None, None, None)
943
feature = tests.Feature()
934
feature = features.Feature()
944
935
class Test(tests.TestCase):
945
936
def test_function(self):
946
937
raise tests.UnavailableFeature(feature)
1191
1173
def test_unsupported_features_listed(self):
1192
1174
"""When unsupported features are encountered they are detailed."""
1193
class Feature1(tests.Feature):
1175
class Feature1(features.Feature):
1194
1176
def _probe(self): return False
1195
class Feature2(tests.Feature):
1177
class Feature2(features.Feature):
1196
1178
def _probe(self): return False
1197
1179
# create sample tests
1198
1180
test1 = SampleTestCase('_test_pass')
1512
1494
def test_requireFeature_available(self):
1513
1495
"""self.requireFeature(available) is a no-op."""
1514
class Available(tests.Feature):
1496
class Available(features.Feature):
1515
1497
def _probe(self):return True
1516
1498
feature = Available()
1517
1499
self.requireFeature(feature)
1519
1501
def test_requireFeature_unavailable(self):
1520
1502
"""self.requireFeature(unavailable) raises UnavailableFeature."""
1521
class Unavailable(tests.Feature):
1503
class Unavailable(features.Feature):
1522
1504
def _probe(self):return False
1523
1505
feature = Unavailable()
1524
1506
self.assertRaises(tests.UnavailableFeature,
2605
2587
self.assertEqual('bzr: interrupted\n', result[1])
2608
class TestFeature(tests.TestCase):
2610
def test_caching(self):
2611
"""Feature._probe is called by the feature at most once."""
2612
class InstrumentedFeature(tests.Feature):
2614
super(InstrumentedFeature, self).__init__()
2617
self.calls.append('_probe')
2619
feature = InstrumentedFeature()
2621
self.assertEqual(['_probe'], feature.calls)
2623
self.assertEqual(['_probe'], feature.calls)
2625
def test_named_str(self):
2626
"""Feature.__str__ should thunk to feature_name()."""
2627
class NamedFeature(tests.Feature):
2628
def feature_name(self):
2630
feature = NamedFeature()
2631
self.assertEqual('symlinks', str(feature))
2633
def test_default_str(self):
2634
"""Feature.__str__ should default to __class__.__name__."""
2635
class NamedFeature(tests.Feature):
2637
feature = NamedFeature()
2638
self.assertEqual('NamedFeature', str(feature))
2641
class TestUnavailableFeature(tests.TestCase):
2643
def test_access_feature(self):
2644
feature = tests.Feature()
2645
exception = tests.UnavailableFeature(feature)
2646
self.assertIs(feature, exception.args[0])
2649
simple_thunk_feature = tests._CompatabilityThunkFeature(
2650
deprecated_in((2, 1, 0)),
2651
'bzrlib.tests.test_selftest',
2652
'simple_thunk_feature','UnicodeFilename',
2653
replacement_module='bzrlib.tests'
2656
class Test_CompatibilityFeature(tests.TestCase):
2658
def test_does_thunk(self):
2659
res = self.callDeprecated(
2660
['bzrlib.tests.test_selftest.simple_thunk_feature was deprecated'
2661
' in version 2.1.0. Use bzrlib.tests.UnicodeFilename instead.'],
2662
simple_thunk_feature.available)
2663
self.assertEqual(tests.UnicodeFilename.available(), res)
2666
class TestModuleAvailableFeature(tests.TestCase):
2668
def test_available_module(self):
2669
feature = tests.ModuleAvailableFeature('bzrlib.tests')
2670
self.assertEqual('bzrlib.tests', feature.module_name)
2671
self.assertEqual('bzrlib.tests', str(feature))
2672
self.assertTrue(feature.available())
2673
self.assertIs(tests, feature.module)
2675
def test_unavailable_module(self):
2676
feature = tests.ModuleAvailableFeature('bzrlib.no_such_module_exists')
2677
self.assertEqual('bzrlib.no_such_module_exists', str(feature))
2678
self.assertFalse(feature.available())
2679
self.assertIs(None, feature.module)
2682
2590
class TestSelftestFiltering(tests.TestCase):
2684
2592
def setUp(self):