74
73
# it's really just a test fixture for test-feature deprecation.
75
74
simple_thunk_feature = features._CompatabilityThunkFeature(
76
75
symbol_versioning.deprecated_in((2, 1, 0)),
77
'breezy.tests.test_features',
76
'brzlib.tests.test_features',
78
77
'simple_thunk_feature',
79
78
'UnicodeFilenameFeature',
80
replacement_module='breezy.tests.features')
79
replacement_module='brzlib.tests.features')
83
82
class Test_CompatibilityFeature(tests.TestCase):
85
84
def test_does_thunk(self):
86
85
res = self.callDeprecated(
87
['breezy.tests.test_features.simple_thunk_feature '
86
['brzlib.tests.test_features.simple_thunk_feature '
88
87
'was deprecated in version 2.1.0. '
89
'Use breezy.tests.features.UnicodeFilenameFeature instead.'],
88
'Use brzlib.tests.features.UnicodeFilenameFeature instead.'],
90
89
simple_thunk_feature.available)
91
90
self.assertEqual(features.UnicodeFilenameFeature.available(), res)
93
92
def test_reports_correct_location(self):
94
93
a_feature = features._CompatabilityThunkFeature(
95
94
symbol_versioning.deprecated_in((2, 1, 0)),
96
'breezy.tests.test_features',
95
'brzlib.tests.test_features',
98
97
'UnicodeFilenameFeature',
99
replacement_module='breezy.tests.features')
98
replacement_module='brzlib.tests.features')
101
99
def test_caller(message, category=None, stacklevel=1):
102
100
# Find ourselves back from the right frame
103
101
caller = sys._getframe(stacklevel)
116
114
class TestModuleAvailableFeature(tests.TestCase):
118
116
def test_available_module(self):
119
feature = features.ModuleAvailableFeature('breezy.tests')
120
self.assertEqual('breezy.tests', feature.module_name)
121
self.assertEqual('breezy.tests', str(feature))
117
feature = features.ModuleAvailableFeature('brzlib.tests')
118
self.assertEqual('brzlib.tests', feature.module_name)
119
self.assertEqual('brzlib.tests', str(feature))
122
120
self.assertTrue(feature.available())
123
121
self.assertIs(tests, feature.module)
125
123
def test_unavailable_module(self):
126
124
feature = features.ModuleAvailableFeature(
127
'breezy.no_such_module_exists')
128
self.assertEqual('breezy.no_such_module_exists', str(feature))
125
'brzlib.no_such_module_exists')
126
self.assertEqual('brzlib.no_such_module_exists', str(feature))
129
127
self.assertFalse(feature.available())
130
128
self.assertIs(None, feature.module)
133
class TestPluginLoadedFeature(tests.TestCase):
135
def test_available_plugin(self):
136
plugins = _mod_plugin.plugins()
138
self.skipTest('no plugins available to test with')
139
a_plugin_name = next(iter(plugins))
140
feature = features.PluginLoadedFeature(a_plugin_name)
141
self.assertEqual(a_plugin_name, feature.plugin_name)
142
self.assertEqual(a_plugin_name + ' plugin', str(feature))
143
self.assertTrue(feature.available())
145
def test_unavailable_plugin(self):
146
feature = features.PluginLoadedFeature('idontexist')
147
self.assertEqual('idontexist plugin', str(feature))
148
self.assertFalse(feature.available())
149
self.assertIs(None, feature.plugin)
152
131
class TestUnicodeFilenameFeature(tests.TestCase):
154
133
def test_probe_passes(self):
156
135
# We can't test much more than that because the behaviour depends
157
136
# on the platform.
158
137
features.UnicodeFilenameFeature._probe()
161
class TestBackslashFilenameFeature(tests.TestCase):
163
def test_probe_passes(self):
164
"""BackslashFilenameFeature._probe passes."""
165
# We can't test much more than that because the behaviour depends
167
features.BackslashFilenameFeature._probe()