Skip to content

asyncio_mode=auto does not support hypothesis without marker #258

Closed
@TheKevJames

Description

@TheKevJames

The new asyncio_mode=auto mode does not support hypothesis markers. I'm assuming this is an issue on the asyncio side, since strict mode continues to work, but please let me know if I should post this to hypothesis instead!

I think @asvetlov and @seifertm are the relevant folks to ping for this.

Reproduction case:

pytest.ini
[pytest]
asyncio_mode = auto
test.py
from hypothesis import given
from hypothesis import strategies as st

@given(x=st.booleans())
async def test_foo(x):
    assert x
» pip install pytest-asyncio hypothesis
» pytest test.py
== test session starts =
platform darwin -- Python 3.7.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /private/tmp/testpyasynchypo, configfile: pytest.ini
plugins: hypothesis-6.35.0, asyncio-0.17.0
collected 1 item                                                                                                                                                                                                            

test.py F                                                                       [100%]

== FAILURES ==
_ test_foo _

    @given(x=st.booleans())
>   async def test_foo(x):
E   hypothesis.errors.InvalidArgument: Hypothesis doesn't know how to run async test functions like test_foo.  You'll need to write a custom executor, or use a library like pytest-asyncio or pytest-trio which can handle the translation for you.
E       See https://hypothesis.readthedocs.io/en/latest/details.html#custom-function-execution

test.py:6: InvalidArgument
== short test summary info ==
FAILED test.py::test_foo - hypothesis.errors.InvalidArgument: Hypothesis doesn't know how to run async test functions like test_foo.  You'll need to write a custom executor, or use a library like pytest-asyncio or pyte...
== 1 failed in 0.22s ==

Comparison, using strict mode, the following works as expected:

pytest.ini
[pytest]
asyncio_mode = strict
test.py
import pytest
from hypothesis import given
from hypothesis import strategies as st

@pytest.mark.asyncio
@given(x=st.booleans())
async def test_foo(x):
    assert x

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions