Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path forward to pytest 4? #6

Open
bsamuel-ui opened this issue Jan 23, 2019 · 2 comments
Open

Path forward to pytest 4? #6

bsamuel-ui opened this issue Jan 23, 2019 · 2 comments

Comments

@bsamuel-ui
Copy link

As of pytest 4.1.1 it looks like yield tests are gone, and the machinery supporting them removed. Is there a solution to this?

@devova
Copy link
Owner

devova commented Jan 25, 2019

Unfortunately, starting from pytest==4.1 generators become deprecated. Of course I can write logic to ignore that behaviour, ignore UserWarnings and unmark tests as skipped, but it would be a hack rather than normal solution.
The way I see is moving to real coroutines with async/await syntax. But it will work only with python3

@bsamuel-ui
Copy link
Author

For what it's worth, my use case for this is to run a battery of tests against a service. So we're not interested in testing multiple versions of python, let alone python 2.

If someone wanted to use this package, and needed tests to work under python 2, a shim like this and sufficiently awful tox.ini would let them work with a python 2 compatible pytest-yield:

if is_3:
    from asyncio import coroutine
else:
    coroutine = lambda func: coroutine

@coroutine
def test_mytest():
     assert a_thing()
     yield  # from something_awaitable()? Can probably simulate that too
     assert another_thing()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants