Skip to content

Commit

Permalink
Move compat tests to a single file using testdir
Browse files Browse the repository at this point in the history
This avoids having to resort to skipping modules in conftest.py file and avoids flake8 errors
  • Loading branch information
nicoddemus committed Dec 13, 2016
1 parent 3a59acf commit 45eb9b5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 34 deletions.
7 changes: 0 additions & 7 deletions testing/conftest.py

This file was deleted.

37 changes: 37 additions & 0 deletions testing/test_compat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import sys

import pytest
from _pytest.compat import is_generator


Expand All @@ -10,3 +13,37 @@ def foo():

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*'])
15 changes: 0 additions & 15 deletions testing/test_compat_3.py

This file was deleted.

12 changes: 0 additions & 12 deletions testing/test_compat_35.py

This file was deleted.

0 comments on commit 45eb9b5

Please sign in to comment.