/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 bzrlib/tests/test_features.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2011, 2016 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
 
19
19
import sys
20
20
 
21
 
from .. import (
22
 
    plugin as _mod_plugin,
 
21
from bzrlib import (
23
22
    symbol_versioning,
24
23
    tests,
25
24
    )
26
 
from . import (
 
25
from bzrlib.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
    'bzrlib.tests.test_features',
78
77
    'simple_thunk_feature',
79
78
    'UnicodeFilenameFeature',
80
 
    replacement_module='breezy.tests.features')
 
79
    replacement_module='bzrlib.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
            ['bzrlib.tests.test_features.simple_thunk_feature '
88
87
             'was deprecated in version 2.1.0. '
89
 
             'Use breezy.tests.features.UnicodeFilenameFeature instead.'],
 
88
             'Use bzrlib.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
            'bzrlib.tests.test_features',
97
96
            'a_feature',
98
97
            'UnicodeFilenameFeature',
99
 
            replacement_module='breezy.tests.features')
 
98
            replacement_module='bzrlib.tests.features')
100
99
        def test_caller(message, category=None, stacklevel=1):
101
100
            # Find ourselves back from the right frame
102
101
            caller = sys._getframe(stacklevel)
103
102
            reported_file = caller.f_globals['__file__']
104
103
            reported_lineno = caller.f_lineno
105
 
            self.assertEqual(__file__, reported_file)
 
104
            self.assertEquals(__file__, reported_file)
106
105
            # The call we're tracking occurred the line after we grabbed the
107
106
            # lineno.
108
 
            self.assertEqual(self.lineno + 1, reported_lineno)
 
107
            self.assertEquals(self.lineno + 1, reported_lineno)
109
108
        self.overrideAttr(symbol_versioning, 'warn', test_caller)
110
109
        # Grab the current lineno
111
110
        self.lineno = sys._getframe().f_lineno
115
114
class TestModuleAvailableFeature(tests.TestCase):
116
115
 
117
116
    def test_available_module(self):
118
 
        feature = features.ModuleAvailableFeature('breezy.tests')
119
 
        self.assertEqual('breezy.tests', feature.module_name)
120
 
        self.assertEqual('breezy.tests', str(feature))
 
117
        feature = features.ModuleAvailableFeature('bzrlib.tests')
 
118
        self.assertEqual('bzrlib.tests', feature.module_name)
 
119
        self.assertEqual('bzrlib.tests', str(feature))
121
120
        self.assertTrue(feature.available())
122
121
        self.assertIs(tests, feature.module)
123
122
 
124
123
    def test_unavailable_module(self):
125
124
        feature = features.ModuleAvailableFeature(
126
 
            'breezy.no_such_module_exists')
127
 
        self.assertEqual('breezy.no_such_module_exists', str(feature))
 
125
            'bzrlib.no_such_module_exists')
 
126
        self.assertEqual('bzrlib.no_such_module_exists', str(feature))
128
127
        self.assertFalse(feature.available())
129
128
        self.assertIs(None, feature.module)
130
129
 
131
130
 
132
 
class TestPluginLoadedFeature(tests.TestCase):
133
 
 
134
 
    def test_available_plugin(self):
135
 
        plugins = _mod_plugin.plugins()
136
 
        if not plugins:
137
 
            self.skipTest('no plugins available to test with')
138
 
        a_plugin_name = next(iter(plugins))
139
 
        feature = features.PluginLoadedFeature(a_plugin_name)
140
 
        self.assertEqual(a_plugin_name, feature.plugin_name)
141
 
        self.assertEqual(a_plugin_name + ' plugin', str(feature))
142
 
        self.assertTrue(feature.available())
143
 
 
144
 
    def test_unavailable_plugin(self):
145
 
        feature = features.PluginLoadedFeature('idontexist')
146
 
        self.assertEqual('idontexist plugin', str(feature))
147
 
        self.assertFalse(feature.available())
148
 
        self.assertIs(None, feature.plugin)
149
 
 
150
 
 
151
131
class TestUnicodeFilenameFeature(tests.TestCase):
152
132
 
153
133
    def test_probe_passes(self):
155
135
        # We can't test much more than that because the behaviour depends
156
136
        # on the platform.
157
137
        features.UnicodeFilenameFeature._probe()
158
 
 
159
 
 
160
 
class TestBackslashFilenameFeature(tests.TestCase):
161
 
 
162
 
    def test_probe_passes(self):
163
 
        """BackslashFilenameFeature._probe passes."""
164
 
        # We can't test much more than that because the behaviour depends
165
 
        # on the platform.
166
 
        features.BackslashFilenameFeature._probe()