mirror of https://github.com/cool-RR/PySnooper.git
Make tests nicer
This commit is contained in:
parent
53bc524b7e
commit
1ef8beb90b
|
@ -25,18 +25,11 @@ def test_rejecting_coroutine_functions():
|
||||||
if sys.version_info[:2] <= (3, 4):
|
if sys.version_info[:2] <= (3, 4):
|
||||||
pytest.skip()
|
pytest.skip()
|
||||||
|
|
||||||
class Thing:
|
|
||||||
pass
|
|
||||||
|
|
||||||
thing = Thing()
|
|
||||||
|
|
||||||
code = textwrap.dedent('''
|
code = textwrap.dedent('''
|
||||||
async def foo(x):
|
async def foo(x):
|
||||||
return 'lol'
|
return 'lol'
|
||||||
thing.foo = foo
|
|
||||||
''')
|
''')
|
||||||
exec(code)
|
exec(code, globals())
|
||||||
foo = thing.foo
|
|
||||||
|
|
||||||
assert pycompat.iscoroutinefunction(foo)
|
assert pycompat.iscoroutinefunction(foo)
|
||||||
assert not pycompat.isasyncgenfunction(foo)
|
assert not pycompat.isasyncgenfunction(foo)
|
||||||
|
@ -48,18 +41,11 @@ def test_rejecting_async_generator_functions():
|
||||||
if sys.version_info[:2] <= (3, 6):
|
if sys.version_info[:2] <= (3, 6):
|
||||||
pytest.skip()
|
pytest.skip()
|
||||||
|
|
||||||
class Thing:
|
|
||||||
pass
|
|
||||||
|
|
||||||
thing = Thing()
|
|
||||||
|
|
||||||
code = textwrap.dedent('''
|
code = textwrap.dedent('''
|
||||||
async def foo(x):
|
async def foo(x):
|
||||||
yield 'lol'
|
yield 'lol'
|
||||||
thing.foo = foo
|
|
||||||
''')
|
''')
|
||||||
exec(code)
|
exec(code, globals())
|
||||||
foo = thing.foo
|
|
||||||
|
|
||||||
assert not pycompat.iscoroutinefunction(foo)
|
assert not pycompat.iscoroutinefunction(foo)
|
||||||
assert pycompat.isasyncgenfunction(foo)
|
assert pycompat.isasyncgenfunction(foo)
|
Loading…
Reference in New Issue