jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[tests] always use TestTimerMixin with TestCaseBase

A lot of tests does not notify the test time used but there are a lot
of tests which are time consuming like wikisource:zh tests and pypy
tests. Use the TestTimerMixin for all tests to get more information
about time usage.

Bug: T186323
Change-Id: I06996f8e4a75a38933e331581cd38a64d4aee28c
---
M tests/aspects.py
1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/tests/aspects.py b/tests/aspects.py
index 3d1ac61..ef26423 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -65,7 +65,30 @@
pywikibot.bot.set_interface('buffer')


-class TestCaseBase(unittest.TestCase):
+class TestTimerMixin(unittest.TestCase):
+
+ """Time each test and report excessive durations."""
+
+ # Number of seconds each test may consume
+ # before a note is added after the test.
+ test_duration_warning_interval = 10
+
+ def setUp(self):
+ """Set up test."""
+ self.test_start = time.time()
+ super().setUp()
+
+ def tearDown(self):
+ """Tear down test."""
+ super().tearDown()
+ self.test_completed = time.time()
+ duration = self.test_completed - self.test_start
+ if duration > self.test_duration_warning_interval:
+ unittest_print(' {0:.3f}s'.format(duration), end=' ')
+ sys.stdout.flush()
+
+
+class TestCaseBase(TestTimerMixin):

"""Base class for all tests."""

@@ -268,31 +291,6 @@
code, info, msg, self).handle(callable_obj, args, kwargs)


-class TestTimerMixin(TestCaseBase):
-
- """Time each test and report excessive durations."""
-
- # Number of seconds each test may consume
- # before a note is added after the test.
- test_duration_warning_interval = 10
-
- def setUp(self):
- """Set up test."""
- super().setUp()
- self.test_start = time.time()
-
- def tearDown(self):
- """Tear down test."""
- self.test_completed = time.time()
- duration = self.test_completed - self.test_start
-
- if duration > self.test_duration_warning_interval:
- unittest_print(' {0:.3f}s'.format(duration), end=' ')
- sys.stdout.flush()
-
- super().tearDown()
-
-
def require_modules(*required_modules):
"""Require that the given list of modules can be imported."""
def test_requirement(obj):
@@ -835,7 +833,7 @@
dct[test_name].__doc__ = doc


-class TestCase(TestTimerMixin, TestCaseBase, metaclass=MetaTestCaseClass):
+class TestCase(TestCaseBase, metaclass=MetaTestCaseClass):

"""Run tests on pre-defined sites."""


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

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