Rev 6331: (vila) Better deprecation warnings for _CompatabilityThunkFeature based test in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Wed Nov 30 08:29:57 UTC 2011


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6331 [merge]
revision-id: pqm at pqm.ubuntu.com-20111130082957-wkkb5rcx24hrzn4x
parent: pqm at pqm.ubuntu.com-20111130013552-9193u1w0j4ts1ibg
parent: v.ladeuil+lp at free.fr-20111129162756-2mc5uztxmd37w5b8
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-11-30 08:29:57 +0000
message:
  (vila) Better deprecation warnings for _CompatabilityThunkFeature based test
   features (Vincent Ladeuil)
modified:
  bzrlib/tests/features.py       features.py-20090820042958-jglgza3wrn03ha9e-1
  bzrlib/tests/test_features.py  test_features.py-20110613213314-g7lqsp2ccxqm5g36-1
  bzrlib/tests/test_trace.py     testtrace.py-20051110225523-a21117fc7a07eeff
  doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== 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