~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_features.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Tests for test feature dependencies.
18
 
"""
 
17
"""Tests for test feature dependencies."""
 
18
 
 
19
import sys
19
20
 
20
21
from bzrlib import (
21
22
    symbol_versioning,
88
89
            simple_thunk_feature.available)
89
90
        self.assertEqual(features.UnicodeFilenameFeature.available(), res)
90
91
 
 
92
    def test_reports_correct_location(self):
 
93
        a_feature = features._CompatabilityThunkFeature(
 
94
            symbol_versioning.deprecated_in((2, 1, 0)),
 
95
            'bzrlib.tests.test_features',
 
96
            'a_feature',
 
97
            'UnicodeFilenameFeature',
 
98
            replacement_module='bzrlib.tests.features')
 
99
        def test_caller(message, category=None, stacklevel=1):
 
100
            # Find ourselves back from the right frame
 
101
            caller = sys._getframe(stacklevel)
 
102
            reported_file = caller.f_globals['__file__']
 
103
            reported_lineno = caller.f_lineno
 
104
            self.assertEquals(__file__, reported_file)
 
105
            # The call we're tracking occurred the line after we grabbed the
 
106
            # lineno.
 
107
            self.assertEquals(self.lineno + 1, reported_lineno)
 
108
        self.overrideAttr(symbol_versioning, 'warn', test_caller)
 
109
        # Grab the current lineno
 
110
        self.lineno = sys._getframe().f_lineno
 
111
        self.requireFeature(a_feature)
 
112
 
91
113
 
92
114
class TestModuleAvailableFeature(tests.TestCase):
93
115