MCPcopy Index your code
hub / github.com/python/cpython / test_func_16

Method test_func_16

Lib/test/test_coroutines.py:789–818  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

787 reader(spammer_coro).send(None)
788
789 def test_func_16(self):
790 # See http://bugs.python.org/issue25887 for details
791
792 @types.coroutine
793 def nop():
794 yield
795 async def send():
796 await nop()
797 return 'spam'
798 async def read(coro):
799 await nop()
800 return await coro
801
802 spammer = send()
803
804 reader = read(spammer)
805 reader.send(None)
806 reader.send(None)
807 with self.assertRaisesRegex(Exception, 'ham'):
808 reader.throw(Exception('ham'))
809
810 reader = read(spammer)
811 reader.send(None)
812 with self.assertRaisesRegex(RuntimeError,
813 'cannot reuse already awaited coroutine'):
814 reader.send(None)
815
816 with self.assertRaisesRegex(RuntimeError,
817 'cannot reuse already awaited coroutine'):
818 reader.throw(Exception('wat'))
819
820 def test_func_17(self):
821 # See http://bugs.python.org/issue25887 for details

Callers

nothing calls this directly

Calls 4

assertRaisesRegexMethod · 0.80
readFunction · 0.70
sendMethod · 0.45
throwMethod · 0.45

Tested by

no test coverage detected