Commit 0fb7c071 authored by Stefan Behnel's avatar Stefan Behnel

unittest fixes and work-arounds for older Python versions

parent 631e8b33
...@@ -224,7 +224,7 @@ class AsyncGenTest(unittest.TestCase): ...@@ -224,7 +224,7 @@ class AsyncGenTest(unittest.TestCase):
if sys.version_info < (3, 3): if sys.version_info < (3, 3):
@contextlib.contextmanager @contextlib.contextmanager
def assertRaisesRegex(self, exc_type, regex): def assertRaisesRegex(self, exc_type, regex=None):
# the error messages usually don't match, so we just ignore them # the error messages usually don't match, so we just ignore them
try: try:
yield yield
...@@ -233,6 +233,16 @@ class AsyncGenTest(unittest.TestCase): ...@@ -233,6 +233,16 @@ class AsyncGenTest(unittest.TestCase):
else: else:
self.assertTrue(False) self.assertTrue(False)
if sys.version_info < (2, 7):
def assertIn(self, x, container):
self.assertTrue(x in container)
def assertIs(self, x, y):
self.assertTrue(x is y)
assertRaises = assertRaisesRegex
def compare_generators(self, sync_gen, async_gen): def compare_generators(self, sync_gen, async_gen):
def sync_iterate(g): def sync_iterate(g):
res = [] res = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment