jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/510556 )
Change subject: [tests] Enable subTest context manager for Python 2 ......................................................................
[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(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
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): """
pywikibot-commits@lists.wikimedia.org