jenkins-bot merged this change.

View Change

Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
[tests] Enable subTest context manager for Python 2

This allows using of subTest with Python 3 inside tests without
breaking Python 2.

Change-Id: I7cc6666ddb51f108f4cbc72405d30c2aba638da8
---
M tests/aspects.py
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/tests/aspects.py b/tests/aspects.py
index ada517d..6695894 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -63,6 +63,12 @@

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

+ if not hasattr(unittest.TestCase, 'subTest'):
+ @contextmanager
+ def subTest(self, *args, **kwargs):
+ """Dummy subTest context manager for Python 2 that does nothing."""
+ yield
+
if not hasattr(unittest.TestCase, 'assertRaisesRegex'):
def assertRaisesRegex(self, *args, **kwargs):
"""

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7cc6666ddb51f108f4cbc72405d30c2aba638da8
Gerrit-Change-Number: 510556
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)