/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to brzlib/tests/test_features.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import sys
20
20
 
21
 
from .. import (
22
 
    plugin as _mod_plugin,
 
21
from brzlib import (
23
22
    symbol_versioning,
24
23
    tests,
25
24
    )
26
 
from . import (
 
25
from brzlib.tests import (
27
26
    features,
28
27
    )
29
28
 
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')
81
80
 
82
81
 
83
82
class Test_CompatibilityFeature(tests.TestCase):
84
83
 
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)
92
91
 
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',
97
96
            'a_feature',
98
97
            'UnicodeFilenameFeature',
99
 
            replacement_module='breezy.tests.features')
100
 
 
 
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):
117
115
 
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)
124
122
 
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)
131
129
 
132
130
 
133
 
class TestPluginLoadedFeature(tests.TestCase):
134
 
 
135
 
    def test_available_plugin(self):
136
 
        plugins = _mod_plugin.plugins()
137
 
        if not 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())
144
 
 
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)
150
 
 
151
 
 
152
131
class TestUnicodeFilenameFeature(tests.TestCase):
153
132
 
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()
159
 
 
160
 
 
161
 
class TestBackslashFilenameFeature(tests.TestCase):
162
 
 
163
 
    def test_probe_passes(self):
164
 
        """BackslashFilenameFeature._probe passes."""
165
 
        # We can't test much more than that because the behaviour depends
166
 
        # on the platform.
167
 
        features.BackslashFilenameFeature._probe()