~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_features.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2011, 2016 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
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.assertEqual(__file__, reported_file)
 
105
            # The call we're tracking occurred the line after we grabbed the
 
106
            # lineno.
 
107
            self.assertEqual(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