diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-29 13:01:29 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-29 13:01:29 (GMT) |
commit | 56fc61402533dc550244efe3e860242872f35bad (patch) | |
tree | 859b4c58dac06f2760d97814f36f8664a50af121 /Lib/test/test_collections.py | |
parent | 8fa6d4f75311bb459da50226c726d1ab7ccf115b (diff) | |
download | cpython-56fc61402533dc550244efe3e860242872f35bad.zip cpython-56fc61402533dc550244efe3e860242872f35bad.tar.gz cpython-56fc61402533dc550244efe3e860242872f35bad.tar.bz2 |
Issue 24315: Make collections.abc.Coroutine derived from Awaitable
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r-- | Lib/test/test_collections.py | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index ec86466..dc79b69 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -496,6 +496,8 @@ class TestOneTrickPonyABCs(ABCTestCase): return value def throw(self, typ, val=None, tb=None): super().throw(typ, val, tb) + def __await__(self): + yield non_samples = [None, int(), gen(), object()] for x in non_samples: @@ -515,13 +517,7 @@ class TestOneTrickPonyABCs(ABCTestCase): self.assertIsInstance(c, Awaitable) c.close() # awoid RuntimeWarning that coro() was not awaited - class CoroLike: - def send(self, value): - pass - def throw(self, typ, val=None, tb=None): - pass - def close(self): - pass + class CoroLike: pass Coroutine.register(CoroLike) self.assertTrue(isinstance(CoroLike(), Awaitable)) self.assertTrue(issubclass(CoroLike, Awaitable)) @@ -548,6 +544,8 @@ class TestOneTrickPonyABCs(ABCTestCase): return value def throw(self, typ, val=None, tb=None): super().throw(typ, val, tb) + def __await__(self): + yield non_samples = [None, int(), gen(), object(), Bar()] for x in non_samples: @@ -567,6 +565,28 @@ class TestOneTrickPonyABCs(ABCTestCase): self.assertIsInstance(c, Coroutine) c.close() # awoid RuntimeWarning that coro() was not awaited + class CoroLike: + def send(self, value): + pass + def throw(self, typ, val=None, tb=None): + pass + def close(self): + pass + def __await__(self): + pass + self.assertTrue(isinstance(CoroLike(), Coroutine)) + self.assertTrue(issubclass(CoroLike, Coroutine)) + + class CoroLike: + def send(self, value): + pass + def close(self): + pass + def __await__(self): + pass + self.assertFalse(isinstance(CoroLike(), Coroutine)) + self.assertFalse(issubclass(CoroLike, Coroutine)) + def test_Hashable(self): # Check some non-hashables non_samples = [bytearray(), list(), set(), dict()] |