jenkins-bot has submitted this change and it was merged.
Change subject: Test deprecated_args decorator for instance methods ......................................................................
Test deprecated_args decorator for instance methods
Change-Id: I9efff43a41a3974c7389d305df7411ab9dd6c024 --- M tests/deprecation_tests.py 1 file changed, 57 insertions(+), 0 deletions(-)
Approvals: XZise: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/deprecation_tests.py b/tests/deprecation_tests.py index b9a662e..3f15506 100644 --- a/tests/deprecation_tests.py +++ b/tests/deprecation_tests.py @@ -165,6 +165,12 @@ self.foo2 = foo2 return (foo, foo2)
+ @deprecated_args(bah='foo', bah2='foo2') + def deprecated_instance_method_args_multi(self, foo, foo2): + self.foo = foo + self.foo2 = foo2 + return (foo, foo2) + @deprecated() @deprecate_arg('bah', 'foo') def deprecated_instance_method_and_arg(self, foo): @@ -662,6 +668,57 @@ self.assertEqual(rv, (1, 2)) self.assertNoDeprecation()
+ def test_deprecated_instance_method_args_multi(self): + """Test @deprecated_args with instance methods and two args.""" + f = DeprecatedMethodClass() + + rv = f.deprecated_instance_method_args_multi('a', 'b') + self.assertEqual(rv, ('a', 'b')) + self.assertNoDeprecation() + + rv = f.deprecated_instance_method_args_multi(bah='b', bah2='c') + self.assertEqual(rv, ('b', 'c')) + self.assertDeprecation( + 'bah argument of ' + __name__ + '.DeprecatedMethodClass.' + 'deprecated_instance_method_args_multi is deprecated; ' + 'use foo instead.') + self.assertDeprecation( + 'bah2 argument of ' + __name__ + '.DeprecatedMethodClass.' + 'deprecated_instance_method_args_multi is deprecated; ' + 'use foo2 instead.') + + DeprecatorTestCase._reset_messages() + + rv = f.deprecated_instance_method_args_multi(foo='b', bah2='c') + self.assertEqual(rv, ('b', 'c')) + self.assertNoDeprecation( + 'bah argument of ' + __name__ + '.DeprecatedMethodClass.' + 'deprecated_instance_method_args_multi is deprecated; ' + 'use foo instead.') + self.assertDeprecation( + 'bah2 argument of ' + __name__ + '.DeprecatedMethodClass.' + 'deprecated_instance_method_args_multi is deprecated; ' + 'use foo2 instead.') + + DeprecatorTestCase._reset_messages() + + rv = f.deprecated_instance_method_args_multi(foo2='c', bah='b') + self.assertEqual(rv, ('b', 'c')) + self.assertDeprecation( + 'bah argument of ' + __name__ + '.DeprecatedMethodClass.' + 'deprecated_instance_method_args_multi is deprecated; ' + 'use foo instead.') + self.assertNoDeprecation( + 'bah2 argument of ' + __name__ + '.DeprecatedMethodClass.' + 'deprecated_instance_method_args_multi is deprecated; ' + 'use foo2 instead.') + + DeprecatorTestCase._reset_messages() + + rv = f.deprecated_instance_method_args_multi(foo=1, foo2=2) + self.assertEqual(rv, (1, 2)) + self.assertNoDeprecation() + def test_deprecated_instance_method_and_arg(self): """Test @deprecate_arg and @deprecated with instance methods.""" f = DeprecatedMethodClass()
pywikibot-commits@lists.wikimedia.org