]> granicus.if.org Git - python/commitdiff
bpo-37099: Silence DeprecationWarning in test_inspect (GH-13679)
authorXtreak <tir.karthi@gmail.com>
Thu, 30 May 2019 12:01:39 +0000 (17:31 +0530)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 30 May 2019 12:01:39 +0000 (05:01 -0700)
Fix DeprecationWarning introduced in aee19f54f6fe45f6b3c906987941e5a8af4468e9

https://bugs.python.org/issue37099

Lib/test/test_inspect.py

index b3aae3a18ecfae6e7662cee0e7a83968392c2919..83a5f7ec1f5385d58eab68e5875764f39a329499 100644 (file)
@@ -750,14 +750,16 @@ class TestClassesAndFunctions(unittest.TestCase):
 
     def assertArgSpecEquals(self, routine, args_e, varargs_e=None,
                             varkw_e=None, defaults_e=None, formatted=None):
-        args, varargs, varkw, defaults = inspect.getargspec(routine)
+        with self.assertWarns(DeprecationWarning):
+            args, varargs, varkw, defaults = inspect.getargspec(routine)
         self.assertEqual(args, args_e)
         self.assertEqual(varargs, varargs_e)
         self.assertEqual(varkw, varkw_e)
         self.assertEqual(defaults, defaults_e)
         if formatted is not None:
-            self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults),
-                             formatted)
+            with self.assertWarns(DeprecationWarning):
+                self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults),
+                                 formatted)
 
     def assertFullArgSpecEquals(self, routine, args_e, varargs_e=None,
                                     varkw_e=None, defaults_e=None,
@@ -774,9 +776,10 @@ class TestClassesAndFunctions(unittest.TestCase):
         self.assertEqual(kwonlydefaults, kwonlydefaults_e)
         self.assertEqual(ann, ann_e)
         if formatted is not None:
-            self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults,
-                                                   kwonlyargs, kwonlydefaults, ann),
-                             formatted)
+            with self.assertWarns(DeprecationWarning):
+                self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults,
+                                                       kwonlyargs, kwonlydefaults, ann),
+                                 formatted)
 
     def test_getargspec(self):
         self.assertArgSpecEquals(mod.eggs, ['x', 'y'], formatted='(x, y)')