jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[tests] Remove assertMethod and assertStringMethod

There is no benefit for these test method
but it decreases readability a lot

Change-Id: I641e9f25ea194a12a0244c9febeb1f6869833b20
---
M tests/aspects.py
M tests/site_tests.py
M tests/ui_tests.py
3 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/tests/aspects.py b/tests/aspects.py
index 5c25e59..28f3ec2 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -93,21 +93,6 @@
msg, 'len(%s) != %s' % (safe_repr(seq), second_len))
self.fail(msg)

- def assertMethod(self, method, *args):
- """Generic method assertion."""
- if not method(*args):
- self.fail('{0!r} ({1!r}) fails'.format(method, args))
-
- def assertStringMethod(self, method, *args):
- """
- Generic string method assertion.
-
- All args must be already converted to a string.
- """
- for arg in args:
- self.assertIsInstance(arg, str)
- self.assertMethod(method, *args)
-
def assertPageInNamespaces(self, page, namespaces):
"""
Assert that Pages is in namespaces.
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 747ffb9..0806f34 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -227,8 +227,8 @@
def test_repr(self):
"""Test __repr__."""
code = self.site.family.obsolete.get(self.code) or self.code
- expect = 'Site("{0}", "{1}")'.format(code, self.family)
- self.assertStringMethod(str.endswith, repr(self.site), expect)
+ expect = 'Site("{}", "{}")'.format(code, self.family)
+ self.assertTrue(repr(self.site).endswith(expect))

def test_base_methods(self):
"""Test cases for BaseSite methods."""
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index ac68cb9..234c16a 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -266,10 +266,10 @@
self.assertLength(w, 1)
self.assertEqual(w[0].category, DeprecationWarning)
message = str(w[0].message)
- self.assertStringMethod(str.startswith, message,
- '"toStdout" parameter is deprecated')
- self.assertStringMethod(str.endswith, message,
- 'use pywikibot.stdout() instead.')
+ self.assertTrue(
+ message.startswith('"toStdout" parameter is deprecated'))
+ self.assertTrue(
+ message.endswith('use pywikibot.stdout() instead.'))

def test_stdout(self):
pywikibot.stdout('output')

To view, visit change 640294. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I641e9f25ea194a12a0244c9febeb1f6869833b20
Gerrit-Change-Number: 640294
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged