diff --git a/testing/conftest.py b/testing/conftest.py deleted file mode 100644 index 76a314837..000000000 --- a/testing/conftest.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys - -collect_ignore = [] -if sys.version_info[0] < 3: - collect_ignore.append("test_compat_3.py") -if sys.version_info < (3, 5): - collect_ignore.append("test_compat_35.py") diff --git a/testing/test_compat.py b/testing/test_compat.py index 185fc3bd6..d704bb807 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -1,3 +1,6 @@ +import sys + +import pytest from _pytest.compat import is_generator @@ -10,3 +13,37 @@ def test_is_generator(): assert is_generator(zap) assert not is_generator(foo) + + +def test_is_generator_asyncio(testdir): + pytest.importorskip('asyncio') + testdir.makepyfile(""" + from _pytest.compat import is_generator + import asyncio + @asyncio.coroutine + def baz(): + yield from [1,2,3] + + def test_is_generator_asyncio(): + assert not is_generator(baz) + """) + result = testdir.runpytest() + result.stdout.fnmatch_lines(['*1 passed*']) + + +@pytest.mark.skipif(sys.version_info < (3, 5), reason='async syntax available in Python 3.5+') +def test_is_generator_async_syntax(testdir): + testdir.makepyfile(""" + from _pytest.compat import is_generator + def test_is_generator_py35(): + async def foo(): + await foo() + + async def bar(): + pass + + assert not is_generator(foo) + assert not is_generator(bar) + """) + result = testdir.runpytest() + result.stdout.fnmatch_lines(['*1 passed*']) diff --git a/testing/test_compat_3.py b/testing/test_compat_3.py deleted file mode 100644 index a1ee0e6f1..000000000 --- a/testing/test_compat_3.py +++ /dev/null @@ -1,15 +0,0 @@ -import pytest -from _pytest.compat import is_generator -try: - import asyncio -except ImportError: - asyncio = None - - -@pytest.mark.skipif(asyncio is None, reason='asyncio is not installed') -def test_is_generator(): - @asyncio.coroutine - def baz(): - yield from [1,2,3] - - assert not is_generator(baz) diff --git a/testing/test_compat_35.py b/testing/test_compat_35.py deleted file mode 100644 index 93eecc920..000000000 --- a/testing/test_compat_35.py +++ /dev/null @@ -1,12 +0,0 @@ -from _pytest.compat import is_generator - - -def test_is_generator_py35(): - async def foo(): - await foo() - - async def bar(): - pass - - assert not is_generator(foo) - assert not is_generator(bar)