jenkins-bot merged this change.
[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.