Commit 71e82aa9 authored by Stefan Behnel's avatar Stefan Behnel

fix tests in Py2

parent 32425ed8
...@@ -840,6 +840,10 @@ class CoroutineTest(unittest.TestCase): ...@@ -840,6 +840,10 @@ class CoroutineTest(unittest.TestCase):
def assertIsNotNone(self, value, msg=None): def assertIsNotNone(self, value, msg=None):
self.assertTrue(value is not None, msg) self.assertTrue(value is not None, msg)
if not hasattr(unittest.TestCase, 'assertIsInstance'):
def assertIsInstance(self, obj, cls, msg=None):
self.assertTrue(isinstance(obj, cls), msg)
def test_gen_1(self): def test_gen_1(self):
def gen(): yield def gen(): yield
self.assertFalse(hasattr(gen, '__await__')) self.assertFalse(hasattr(gen, '__await__'))
...@@ -1225,7 +1229,10 @@ class CoroutineTest(unittest.TestCase): ...@@ -1225,7 +1229,10 @@ class CoroutineTest(unittest.TestCase):
result = run_async__await__(foo()) result = run_async__await__(foo())
self.assertIsInstance(result[1], StopIteration) self.assertIsInstance(result[1], StopIteration)
if sys.version_info[0] >= 3:
self.assertEqual(result[1].value, 10) self.assertEqual(result[1].value, 10)
else:
self.assertEqual(result[1].args[0], 10)
def test_cr_await(self): def test_cr_await(self):
@types_coroutine @types_coroutine
...@@ -1493,6 +1500,7 @@ class CoroutineTest(unittest.TestCase): ...@@ -1493,6 +1500,7 @@ class CoroutineTest(unittest.TestCase):
return await f() return await f()
_, result = run_async(g()) _, result = run_async(g())
if sys.version_info[0] >= 3:
self.assertIsNone(result.__context__) self.assertIsNone(result.__context__)
# removed from CPython ? # removed from CPython ?
...@@ -2168,7 +2176,10 @@ class CoroutineTest(unittest.TestCase): ...@@ -2168,7 +2176,10 @@ class CoroutineTest(unittest.TestCase):
if self.i: if self.i:
raise StopAsyncIteration raise StopAsyncIteration
self.i += 1 self.i += 1
if sys.version_info[0] >= 3:
return self.value return self.value
else:
return self.args[0]
result = [] result = []
async def foo(): async def foo():
......
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