Rev 6326: Give meaningful deprecation warnings for deprecated test features in file:///home/vila/src/bzr/bugs/897718-deprecation-warning/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue Nov 29 16:27:56 UTC 2011
At file:///home/vila/src/bzr/bugs/897718-deprecation-warning/
------------------------------------------------------------
revno: 6326
revision-id: v.ladeuil+lp at free.fr-20111129162756-2mc5uztxmd37w5b8
parent: pqm at pqm.ubuntu.com-20111129125756-zmz58wibn2o1c6kb
fixes bug: https://launchpad.net/bugs/897718
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 897718-deprecation-warning
timestamp: Tue 2011-11-29 17:27:56 +0100
message:
Give meaningful deprecation warnings for deprecated test features
-------------- next part --------------
=== modified file 'bzrlib/tests/features.py'
--- a/bzrlib/tests/features.py 2011-11-24 10:47:43 +0000
+++ b/bzrlib/tests/features.py 2011-11-29 16:27:56 +0000
@@ -140,7 +140,8 @@
% (self._module, self._name))
use_msg = ' Use %s.%s instead.' % (self._replacement_module,
self._replacement_name)
- symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning)
+ symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning,
+ stacklevel=5)
# Import the new feature and use it as a replacement for the
# deprecated one.
self._feature = pyutils.get_named_object(
=== modified file 'bzrlib/tests/test_features.py'
--- a/bzrlib/tests/test_features.py 2011-07-11 06:47:32 +0000
+++ b/bzrlib/tests/test_features.py 2011-11-29 16:27:56 +0000
@@ -14,8 +14,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-"""Tests for test feature dependencies.
-"""
+"""Tests for test feature dependencies."""
+
+import sys
from bzrlib import (
symbol_versioning,
@@ -88,6 +89,27 @@
simple_thunk_feature.available)
self.assertEqual(features.UnicodeFilenameFeature.available(), res)
+ def test_reports_correct_location(self):
+ a_feature = features._CompatabilityThunkFeature(
+ symbol_versioning.deprecated_in((2, 1, 0)),
+ 'bzrlib.tests.test_features',
+ 'a_feature',
+ 'UnicodeFilenameFeature',
+ replacement_module='bzrlib.tests.features')
+ def test_caller(message, category=None, stacklevel=1):
+ # Find ourselves back from the right frame
+ caller = sys._getframe(stacklevel)
+ reported_file = caller.f_globals['__file__']
+ reported_lineno = caller.f_lineno
+ self.assertEquals(__file__, reported_file)
+ # The call we're tracking occurred the line after we grabbed the
+ # lineno.
+ self.assertEquals(self.lineno + 1, reported_lineno)
+ self.overrideAttr(symbol_versioning, 'warn', test_caller)
+ # Grab the current lineno
+ self.lineno = sys._getframe().f_lineno
+ self.requireFeature(a_feature)
+
class TestModuleAvailableFeature(tests.TestCase):
=== modified file 'bzrlib/tests/test_trace.py'
--- a/bzrlib/tests/test_trace.py 2011-09-16 12:03:53 +0000
+++ b/bzrlib/tests/test_trace.py 2011-11-29 16:27:56 +0000
@@ -254,7 +254,7 @@
# have to do a replaceent here as well.
self.assertContainsRe(log, "ascii argument: \xb5".decode('utf8',
'replace'))
-
+
def test_show_error(self):
show_error('error1')
show_error(u'error2 \xb5 blah')
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-11-29 12:57:56 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-11-29 16:27:56 +0000
@@ -82,6 +82,10 @@
and gives a better error message if the time zone offset is not given.
(Matt Giuca, #892657)
+* Give meaningful file/line references when reporting deprecation warnings
+ for _CompatabilityThunkFeature based test features.
+ (Vincent Ladeuil, #897718)
+
* Raise BadIndexKey exception in btree_index when a key is too large, fixing
an infinite recursion issue. (Shannon Weyrick, #720853)
More information about the bazaar-commits
mailing list