<s> """<STR_LIT>""" <EOL> import itertools <EOL> import functools <EOL> import pytest <EOL> class CoroutineTestCase ( object ) : <EOL> """<STR_LIT>""" <EOL> def run_until_complete ( self , * coroutines ) : <EOL> """<STR_LIT>""" <EOL> looping_coroutines = itertools . cycle ( coroutines ) <EOL> data = None <EOL> for coro in looping_coroutines : <EOL> try : <EOL> data = coro . send ( data ) <EOL> except StopIteration : <EOL> break <EOL> for coro in coroutines : <EOL> try : <EOL> next ( coro ) <EOL> except StopIteration : <EOL> continue <EOL> else : <EOL> pytest . fail ( "<STR_LIT>" % coro ) <EOL> def server ( self , func ) : <EOL> """<STR_LIT>""" <EOL> @ functools . wraps ( func ) <EOL> def wrapper ( * args , ** kwargs ) : <EOL> c = func ( * args , ** kwargs ) <EOL> next ( c ) <EOL> return c <EOL> return wrapper </s>
