From: Xtreak Date: Thu, 30 May 2019 12:01:39 +0000 (+0530) Subject: bpo-37099: Silence DeprecationWarning in test_inspect (GH-13679) X-Git-Tag: v3.8.0b1~120 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d0b7470a4738a403ef48cfd50d9447e0f32f00c;p=python bpo-37099: Silence DeprecationWarning in test_inspect (GH-13679) Fix DeprecationWarning introduced in aee19f54f6fe45f6b3c906987941e5a8af4468e9 https://bugs.python.org/issue37099 --- diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index b3aae3a18e..83a5f7ec1f 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -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)')