jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] tests: Add method for deprecation parts
......................................................................
[IMPROV] tests: Add method for deprecation parts
Similar to `issue_deprecation_warning` this adds support for methods which just
take the two parts and construct the complete message from that:
* `assertDeprecationParts`
* `assertOneDeprecationParts`
The `assertOneDeprecationParts` and `assertOneDeprecation` can now also support
that there are multiple messages but all of the same type.
Change-Id: Ia77765331f6002f4805e83d3fa7eb3a0e59253e6
---
M tests/aspects.py
M tests/deprecation_tests.py
M tests/dry_site_tests.py
M tests/exceptions_tests.py
M tests/family_tests.py
M tests/logentry_tests.py
M tests/site_tests.py
M tests/tools_ip_tests.py
8 files changed, 162 insertions(+), 152 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 0ab8a13..42d2f06 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -1324,6 +1324,11 @@
TestCase.assertRaisesRegexp,
]
+ # Require no instead string
+ NO_INSTEAD = object()
+ # Require an instead string
+ INSTEAD = object()
+
# Python 3 component in the call stack of _AssertRaisesContext
if hasattr(unittest.case, '_AssertRaisesBaseContext'):
skip_list.append(unittest.case._AssertRaisesBaseContext)
@@ -1353,16 +1358,75 @@
messages = [str(item.message) for item in self.warning_log]
return messages
+ @classmethod
+ def _build_message(cls, deprecated, instead):
+ if deprecated is None:
+ if instead is None:
+ msg = None
+ elif instead is True:
+ msg = cls.INSTEAD
+ else:
+ assert instead is False
+ msg = cls.NO_INSTEAD
+ else:
+ msg = '{0} is deprecated'.format(deprecated)
+ if instead:
+ msg += ', use {0} instead'.format(instead)
+ msg += '.'
+ return msg
+
+ def assertDeprecationParts(self, deprecated=None, instead=None):
+ """
+ Assert that a deprecation warning happened.
+
+ To simplify deprecation tests it just requires the to separated parts
+ and forwards the result to L{assertDeprecation}.
+
+ @param deprecated: The deprecated string. If None it uses a generic
+ match depending on instead.
+ @type deprecated: str or None
+ @param instead: The instead string unless deprecated is None. If it's
+ None it allows any generic deprecation string, on True only those
+ where instead string is present and on False only those where it's
+ missing. If the deprecation string is not None, no instead string
+ is expected when instead evaluates to False.
+ @type instead: str or None or True or False
+ """
+ self.assertDeprecation(self._build_message(deprecated, instead))
+
def assertDeprecation(self, msg=None):
- """Assert that a deprecation warning happened."""
- if msg is None:
- self.assertGreater(sum(1 for msg in self.deprecation_messages
- if self._generic_match.match(msg)), 0)
+ """
+ Assert that a deprecation warning happened.
+
+ @param msg: Either the specific message or None to allow any generic
+ message. When set to C{INSTEAD} it only counts those supplying an
+ alternative and when C{NO_INSTEAD} only those not supplying one.
+ @type msg: string or None or INSTEAD or NO_INSTEAD
+ """
+ if msg is None or msg is self.INSTEAD or msg is self.NO_INSTEAD:
+ deprecation_messages = self.deprecation_messages
+ for deprecation_message in deprecation_messages:
+ match = self._generic_match.match(deprecation_message)
+ if (match and bool(match.group(1)) == (msg is self.INSTEAD) or
+ msg is None):
+ break
+ else:
+ self.fail('No generic deprecation message match found in '
+ '{0}'.format(deprecation_messages))
else:
self.assertIn(msg, self.deprecation_messages)
if self._do_test_warning_filename:
self.assertDeprecationFile(self.expect_warning_filename)
+ def assertOneDeprecationParts(self, deprecated=None, instead=None, count=1):
+ """
+ Assert that exactly one deprecation message happened and reset.
+
+ It uses the same arguments as L{assertDeprecationParts}.
+ """
+ self.assertOneDeprecation(self._build_message(deprecated, instead),
+ count)
+
def assertOneDeprecation(self, msg=None, count=1):
"""Assert that exactly one deprecation message happened and
reset."""
self.assertDeprecation(msg)
diff --git a/tests/deprecation_tests.py b/tests/deprecation_tests.py
index c13a229..e7f4fa9 100644
--- a/tests/deprecation_tests.py
+++ b/tests/deprecation_tests.py
@@ -224,71 +224,52 @@
"""Test @deprecated with functions, with zero
arguments."""
rv = deprecated_func()
self.assertEqual(rv, None)
- self.assertDeprecation(
- __name__ + '.deprecated_func is deprecated.')
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func')
def test_deprecated_function(self):
"""Test @deprecated with functions."""
rv = deprecated_func('a')
self.assertEqual(rv, 'a')
- self.assertDeprecation(
- __name__ + '.deprecated_func is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func')
rv = deprecated_func(1)
self.assertEqual(rv, 1)
- self.assertDeprecation(
- __name__ + '.deprecated_func is deprecated.')
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func')
def test_deprecated_function2(self):
"""Test @deprecated with functions."""
rv = deprecated_func2('a')
self.assertEqual(rv, 'a')
- self.assertDeprecation(
- __name__ + '.deprecated_func2 is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func2')
rv = deprecated_func2(1)
self.assertEqual(rv, 1)
- self.assertDeprecation(
- __name__ + '.deprecated_func2 is deprecated.')
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func2')
def test_deprecated_function_instead(self):
"""Test @deprecated with functions, using
instead."""
rv = deprecated_func_instead('a')
self.assertEqual(rv, 'a')
- self.assertDeprecation(
- __name__ + '.deprecated_func_instead is deprecated, use baz
instead.')
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func_instead',
+ 'baz')
def test_deprecated_function_bad_args(self):
rv = deprecated_func_bad_args(None)
self.assertEqual(rv, None)
- self.assertDeprecation(
- __name__ + '.deprecated_func_bad_args is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func_bad_args')
rv = deprecated_func_bad_args('a')
self.assertEqual(rv, 'a')
- self.assertDeprecation(
- __name__ + '.deprecated_func_bad_args is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func_bad_args')
rv = deprecated_func_bad_args(1)
self.assertEqual(rv, 1)
- self.assertDeprecation(
- __name__ + '.deprecated_func_bad_args is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func_bad_args')
f = DeprecatedMethodClass()
rv = deprecated_func_bad_args(f)
self.assertEqual(rv, f)
- self.assertDeprecation(
- __name__ + '.deprecated_func_bad_args is deprecated.')
+ self.assertOneDeprecationParts(__name__ + '.deprecated_func_bad_args')
def test_deprecated_instance_method(self):
f = DeprecatedMethodClass()
@@ -296,24 +277,20 @@
rv = f.instance_method()
self.assertEqual(rv, None)
self.assertEqual(f.foo, None)
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.instance_method is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.instance_method')
rv = f.instance_method('a')
self.assertEqual(rv, 'a')
self.assertEqual(f.foo, 'a')
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.instance_method is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.instance_method')
rv = f.instance_method(1)
self.assertEqual(rv, 1)
self.assertEqual(f.foo, 1)
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.instance_method is deprecated.')
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.instance_method')
def test_deprecated_instance_method2(self):
f = DeprecatedMethodClass()
@@ -321,65 +298,60 @@
rv = f.instance_method2()
self.assertEqual(rv, None)
self.assertEqual(f.foo, None)
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.instance_method2 is deprecated.')
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.instance_method2')
def test_deprecated_class_method(self):
"""Test @deprecated with class methods."""
rv = DeprecatedMethodClass.class_method()
self.assertEqual(rv, None)
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.class_method is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.class_method')
rv = DeprecatedMethodClass.class_method('a')
self.assertEqual(rv, 'a')
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.class_method is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.class_method')
rv = DeprecatedMethodClass.class_method(1)
self.assertEqual(rv, 1)
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.class_method is deprecated.')
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.class_method')
def test_deprecated_static_method_zero_args(self):
"""Test @deprecated with static methods, with zero
arguments."""
rv = DeprecatedMethodClass.static_method()
self.assertEqual(rv, None)
- self.assertDeprecation(__name__ + '.DeprecatedMethodClass.static_method is
deprecated.')
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.static_method')
def test_deprecated_static_method(self):
"""Test @deprecated with static methods."""
rv = DeprecatedMethodClass.static_method('a')
self.assertEqual(rv, 'a')
- self.assertDeprecation(__name__ + '.DeprecatedMethodClass.static_method is
deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.static_method')
rv = DeprecatedMethodClass.static_method(1)
self.assertEqual(rv, 1)
- self.assertDeprecation(__name__ + '.DeprecatedMethodClass.static_method is
deprecated.')
+ self.assertOneDeprecationParts(
+ __name__ + '.DeprecatedMethodClass.static_method')
def test_deprecate_class_zero_arg(self):
"""Test @deprecated with classes, without
arguments."""
df = DeprecatedClassNoInit()
self.assertEqual(df.__doc__, 'Deprecated class.')
- self.assertDeprecation(__name__ + '.DeprecatedClassNoInit is
deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(__name__ + '.DeprecatedClassNoInit')
df = DeprecatedClass()
self.assertEqual(df.foo, None)
- self.assertDeprecation(__name__ + '.DeprecatedClass is deprecated.')
+ self.assertOneDeprecationParts(__name__ + '.DeprecatedClass')
def test_deprecate_class(self):
"""Test @deprecated with classes."""
df = DeprecatedClass('a')
self.assertEqual(df.foo, 'a')
- self.assertDeprecation(__name__ + '.DeprecatedClass is deprecated.')
+ self.assertOneDeprecationParts(__name__ + '.DeprecatedClass')
def test_deprecate_function_arg(self):
def tests(func):
@@ -419,27 +391,25 @@
self.assertEqual(rv, None)
self.assertNoDeprecation()
+ rv = deprecated_func_arg3(2)
+ self.assertEqual(rv, 2)
+ self.assertNoDeprecation()
+
rv = deprecated_func_arg3(foo=1, silent=42)
self.assertEqual(rv, 1)
self.assertDeprecationClass(PendingDeprecationWarning)
-
- rv = deprecated_func_arg3(2)
- self.assertEqual(rv, 2)
- self.assertDeprecationClass(PendingDeprecationWarning)
+ self.assertOneDeprecationParts(
+ 'silent argument of ' + __name__ + '.deprecated_func_arg3')
rv = deprecated_func_arg3(3, loud='3')
self.assertEqual(rv, 3)
- self.assertDeprecation('loud argument of ' + __name__ +
- '.deprecated_func_arg3 is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ 'loud argument of ' + __name__ + '.deprecated_func_arg3')
rv = deprecated_func_arg3(4, old='4')
self.assertEqual(rv, 4)
- self.assertDeprecation('old argument of ' + __name__ +
- '.deprecated_func_arg3 is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ 'old argument of ' + __name__ + '.deprecated_func_arg3')
def test_function_remove_last_args(self):
"""Test @remove_last_args on functions."""
@@ -735,19 +705,14 @@
rv = f.deprecated_instance_method_and_arg('a')
self.assertEqual(rv, 'a')
self.assertEqual(f.foo, 'a')
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.deprecated_instance_method_and_arg is
deprecated.')
- self.assertNoDeprecation(
- 'bah argument of ' + __name__ + '.DeprecatedMethodClass.'
- 'deprecated_instance_method_and_arg is deprecated; use foo
instead.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ __name__ +
'.DeprecatedMethodClass.deprecated_instance_method_and_arg')
rv = f.deprecated_instance_method_and_arg(bah='b')
self.assertEqual(rv, 'b')
self.assertEqual(f.foo, 'b')
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.deprecated_instance_method_and_arg is
deprecated.')
+ self.assertDeprecationParts(
+ __name__ +
'.DeprecatedMethodClass.deprecated_instance_method_and_arg')
self.assertDeprecation(
'bah argument of ' + __name__ + '.DeprecatedMethodClass.'
'deprecated_instance_method_and_arg is deprecated; use foo
instead.')
@@ -757,11 +722,8 @@
rv = f.deprecated_instance_method_and_arg(foo=1)
self.assertEqual(rv, 1)
self.assertEqual(f.foo, 1)
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.deprecated_instance_method_and_arg is
deprecated.')
- self.assertNoDeprecation(
- 'bah argument of ' + __name__ + '.DeprecatedMethodClass.'
- 'deprecated_instance_method_and_arg is deprecated; use foo
instead.')
+ self.assertOneDeprecationParts(
+ __name__ +
'.DeprecatedMethodClass.deprecated_instance_method_and_arg')
def test_deprecated_instance_method_and_arg2(self):
"""Test @deprecated and @deprecate_arg with instance
methods."""
@@ -770,19 +732,14 @@
rv = f.deprecated_instance_method_and_arg2('a')
self.assertEqual(rv, 'a')
self.assertEqual(f.foo, 'a')
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.deprecated_instance_method_and_arg2 is
deprecated.')
- self.assertNoDeprecation(
- 'bah argument of ' + __name__ + '.DeprecatedMethodClass.'
- 'deprecated_instance_method_and_arg2 is deprecated; use foo
instead.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ __name__ +
'.DeprecatedMethodClass.deprecated_instance_method_and_arg2')
rv = f.deprecated_instance_method_and_arg2(bah='b')
self.assertEqual(rv, 'b')
self.assertEqual(f.foo, 'b')
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.deprecated_instance_method_and_arg2 is
deprecated.')
+ self.assertDeprecationParts(
+ __name__ +
'.DeprecatedMethodClass.deprecated_instance_method_and_arg2')
self.assertDeprecation(
'bah argument of ' + __name__ + '.DeprecatedMethodClass.'
'deprecated_instance_method_and_arg2 is deprecated; use foo
instead.')
@@ -792,11 +749,8 @@
rv = f.deprecated_instance_method_and_arg2(foo=1)
self.assertEqual(rv, 1)
self.assertEqual(f.foo, 1)
- self.assertDeprecation(
- __name__ + '.DeprecatedMethodClass.deprecated_instance_method_and_arg2 is
deprecated.')
- self.assertNoDeprecation(
- 'bah argument of ' + __name__ + '.DeprecatedMethodClass.'
- 'deprecated_instance_method_and_arg2 is deprecated; use foo
instead.')
+ self.assertOneDeprecationParts(
+ __name__ +
'.DeprecatedMethodClass.deprecated_instance_method_and_arg2')
if __name__ == '__main__':
diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py
index b97356d..551881e 100644
--- a/tests/dry_site_tests.py
+++ b/tests/dry_site_tests.py
@@ -232,20 +232,18 @@
NotImplementedError,
'deprecated_unavailable_method2',
self.deprecated_unavailable_method2)
- self.assertDeprecation(
- __name__ + '.TestNeedVersion.deprecated_unavailable_method2 is
deprecated.')
+ self.assertOneDeprecationParts(
+ __name__ + '.TestNeedVersion.deprecated_unavailable_method2')
def test_need_version_success_with_deprecated(self):
"""Test order of combined version check and deprecation
warning."""
self.deprecated_available_method()
- self.assertDeprecation(
- __name__ + '.TestNeedVersion.deprecated_available_method is
deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ __name__ + '.TestNeedVersion.deprecated_available_method')
self.deprecated_available_method2()
- self.assertDeprecation(
- __name__ + '.TestNeedVersion.deprecated_available_method2 is
deprecated.')
+ self.assertOneDeprecationParts(
+ __name__ + '.TestNeedVersion.deprecated_available_method2')
if __name__ == '__main__':
diff --git a/tests/exceptions_tests.py b/tests/exceptions_tests.py
index eed0a08..252877b 100644
--- a/tests/exceptions_tests.py
+++ b/tests/exceptions_tests.py
@@ -34,11 +34,8 @@
# But it sholdnt be accessed from the exceptions module.
cls = pywikibot.exceptions.UploadWarning
- self.assertDeprecation(
- 'pywikibot.exceptions.UploadWarning is deprecated, '
- 'use pywikibot.data.api.UploadWarning instead.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts('pywikibot.exceptions.UploadWarning',
+ 'pywikibot.data.api.UploadWarning')
e = cls('foo', 'bar')
self.assertIsInstance(e, pywikibot.Error)
@@ -53,10 +50,8 @@
e = cls('foo')
self.assertIsInstance(e, pywikibot.Error)
- self.assertDeprecation(
- 'pywikibot.exceptions.DeprecatedPageNotFoundError is deprecated.')
-
- self._reset_messages()
+ self.assertOneDeprecationParts(
+ 'pywikibot.exceptions.DeprecatedPageNotFoundError')
cls = pywikibot.exceptions.PageNotFound
@@ -66,8 +61,8 @@
e = cls('foo')
self.assertIsInstance(e, pywikibot.Error)
- self.assertDeprecation(
- 'pywikibot.exceptions.DeprecatedPageNotFoundError is deprecated.')
+ self.assertOneDeprecationParts(
+ 'pywikibot.exceptions.DeprecatedPageNotFoundError')
if __name__ == '__main__':
diff --git a/tests/family_tests.py b/tests/family_tests.py
index 6fe8823..ffe9b5a 100644
--- a/tests/family_tests.py
+++ b/tests/family_tests.py
@@ -196,8 +196,8 @@
self.assertEqual(f.name, 'species')
f = pywikibot.site.Family('osm')
self.assertEqual(f.name, 'osm')
- self.assertDeprecation(
- 'pywikibot.site.Family is deprecated, use pywikibot.family.Family.load
instead.')
+ self.assertOneDeprecationParts('pywikibot.site.Family',
+ 'pywikibot.family.Family.load', 2)
# @deprecated warning occurs within redirect_func's call
# invoking the method instead of this test module.
@@ -205,9 +205,9 @@
f = pywikibot.site.Family('i18n', fatal=False)
self.assertEqual(f.name, 'i18n')
- self.assertDeprecation(
- 'pywikibot.site.Family is deprecated, use pywikibot.family.Family.load
instead.')
- self.assertDeprecation('fatal argument of pywikibot.family.Family.load is
deprecated.')
+ self.assertDeprecationParts('pywikibot.site.Family',
+ 'pywikibot.family.Family.load')
+ self.assertDeprecationParts('fatal argument of
pywikibot.family.Family.load')
def test_old_site_family_function_invalid(self):
"""Test that an invalid family raised UnknownFamily
exception."""
@@ -217,9 +217,9 @@
self.assertRaises(UnknownFamily, pywikibot.site.Family, 'unknown',
fatal=False)
self.assertRaises(UnknownFamily, pywikibot.site.Family, 'unknown')
- self.assertDeprecation(
- 'pywikibot.site.Family is deprecated, use pywikibot.family.Family.load
instead.')
- self.assertDeprecation('fatal argument of pywikibot.family.Family.load is
deprecated.')
+ self.assertDeprecationParts('pywikibot.site.Family',
+ 'pywikibot.family.Family.load')
+ self.assertDeprecationParts('fatal argument of
pywikibot.family.Family.load')
if __name__ == '__main__':
diff --git a/tests/logentry_tests.py b/tests/logentry_tests.py
index e81a173..e913da7 100644
--- a/tests/logentry_tests.py
+++ b/tests/logentry_tests.py
@@ -221,12 +221,12 @@
"""Test deprecated MoveEntry methods."""
logentry = self._get_logentry('move')
self.assertIsInstance(logentry.new_ns(), int)
- self.assertEqual(logentry.new_title(), logentry.target_page)
+ self.assertOneDeprecationParts('pywikibot.logentries.MoveEntry.new_ns',
+ 'target_ns.id')
- self.assertDeprecation('pywikibot.logentries.MoveEntry.new_ns is '
- 'deprecated, use target_ns.id instead.')
- self.assertDeprecation('pywikibot.logentries.MoveEntry.new_title is '
- 'deprecated, use target_page instead.')
+ self.assertEqual(logentry.new_title(), logentry.target_page)
+ self.assertOneDeprecationParts(
+ 'pywikibot.logentries.MoveEntry.new_title', 'target_page')
def test_LogEntry_title(self, key):
"""Test title and page return the same
instance."""
@@ -255,8 +255,8 @@
# main page was moved back again, we test it.
self.assertEqual(mainpage, target.getMovedTarget())
- self.assertDeprecation('pywikibot.page.BasePage.getMovedTarget is '
- 'deprecated, use moved_target() instead.')
+ self.assertOneDeprecationParts(
+ 'pywikibot.page.BasePage.getMovedTarget', 'moved_target()',
2)
def test_moved_target_fail_old(self):
"""Test getMovedTarget method failing on older
wiki."""
@@ -264,8 +264,8 @@
with self.assertRaises(pywikibot.NoPage):
self.get_mainpage(site).getMovedTarget()
- self.assertDeprecation('pywikibot.page.BasePage.getMovedTarget is '
- 'deprecated, use moved_target() instead.')
+ self.assertOneDeprecationParts('pywikibot.page.BasePage.getMovedTarget',
+ 'moved_target()')
def test_moved_target_fail_de(self):
"""Test getMovedTarget method failing on
de-wiki."""
@@ -273,8 +273,8 @@
with self.assertRaises(pywikibot.NoPage):
page.getMovedTarget()
- self.assertDeprecation('pywikibot.page.BasePage.getMovedTarget is '
- 'deprecated, use moved_target() instead.')
+ self.assertOneDeprecationParts('pywikibot.page.BasePage.getMovedTarget',
+ 'moved_target()')
if __name__ == '__main__':
diff --git a/tests/site_tests.py b/tests/site_tests.py
index f8705bc..0b9c726 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -61,8 +61,8 @@
"Action '[a-z]+' is not allowed for user .* on .*
wiki.")
else:
self.assertEqual(token, mysite.token(mainpage, ttype))
- self.assertDeprecation("pywikibot.site.APISite.token is
deprecated"
- ", use the 'tokens' property
instead.")
+ self.assertOneDeprecationParts('pywikibot.site.APISite.token',
+ "the 'tokens' property")
class TestSiteObjectDeprecatedFunctions(DefaultSiteTestCase, DeprecationTestCase):
@@ -99,12 +99,12 @@
old = self.site.siteinfo('general')
self.assertIn('DUMMY', old)
self.assertNotEqual(self.site.siteinfo('general', force=True), old)
- self.assertDeprecation('Calling siteinfo is deprecated, use itself
instead.')
+ self.assertOneDeprecationParts('Calling siteinfo', 'itself', 4)
def test_siteinfo_dump(self):
"""Test calling the Siteinfo with dump=True."""
self.assertIn('statistics', self.site.siteinfo('statistics',
dump=True))
- self.assertDeprecation('Calling siteinfo is deprecated, use itself
instead.')
+ self.assertOneDeprecationParts('Calling siteinfo', 'itself')
def test_language_method(self):
"""Test if the language method returns the same as the lang
property."""
@@ -137,8 +137,8 @@
"""Test that namespaces is callable and returns
itself."""
site = self.get_site()
self.assertIs(site.namespaces(), site.namespaces)
- self.assertDeprecation('Calling the namespaces property is deprecated, '
- 'use it directly instead.')
+ self.assertOneDeprecationParts('Calling the namespaces property',
+ 'it directly')
class TestBaseSiteProperties(TestCase):
diff --git a/tests/tools_ip_tests.py b/tests/tools_ip_tests.py
index 6e9c46f..fb9ea1a 100644
--- a/tests/tools_ip_tests.py
+++ b/tests/tools_ip_tests.py
@@ -650,8 +650,7 @@
self._test_T76286_failures()
self._test_T105443_failures()
self.assertEqual(self.fail, 0)
- self.assertDeprecation(
- 'page.ip_regexp is deprecated, use tools.ip.is_IP instead.')
+ self.assertDeprecationParts('page.ip_regexp', 'tools.ip.is_IP')
self.assertEqual(self.total, len(self.deprecation_messages))
--
To view, visit
https://gerrit.wikimedia.org/r/228577
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia77765331f6002f4805e83d3fa7eb3a0e59253e6
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>