Make tests nicer

This commit is contained in:
Ram Rachum 2019-09-13 21:03:45 +03:00
parent 53bc524b7e
commit 1ef8beb90b
1 changed files with 2 additions and 16 deletions

View File

@ -25,18 +25,11 @@ def test_rejecting_coroutine_functions():
if sys.version_info[:2] <= (3, 4):
pytest.skip()
class Thing:
pass
thing = Thing()
code = textwrap.dedent('''
async def foo(x):
return 'lol'
thing.foo = foo
''')
exec(code)
foo = thing.foo
exec(code, globals())
assert pycompat.iscoroutinefunction(foo)
assert not pycompat.isasyncgenfunction(foo)
@ -48,18 +41,11 @@ def test_rejecting_async_generator_functions():
if sys.version_info[:2] <= (3, 6):
pytest.skip()
class Thing:
pass
thing = Thing()
code = textwrap.dedent('''
async def foo(x):
yield 'lol'
thing.foo = foo
''')
exec(code)
foo = thing.foo
exec(code, globals())
assert not pycompat.iscoroutinefunction(foo)
assert pycompat.isasyncgenfunction(foo)