Skip to content

async fixtures are incompatible with pytest 3.7.0 #89

Closed
pytest-dev/pytest
#3754

Description

@brycedrennan

Not sure exactly what the issue is yet but test suite passes in pytest==3.6.* but fails in the very recently released pytest 3.7.0.

Activity

  1. Gr1N commented on Jul 31, 2018

    @Gr1N

    Got same issue, any ideas?

  2. brycedrennan commented on Jul 31, 2018

    @brycedrennan
    Author

    For now I've just pinned my pytest to 3.6.4

  3. jwldk commented on Jul 31, 2018

    @jwldk

    Same problem here. Get this error:

    E TypeError: 'coroutine' object is not subscriptable

    when trying to use a async fixture in a test. Works with pytest 3.6.4. Doesn't even appear to be anything related in the pytest changelog.

  4. JohanLorenzo commented on Jul 31, 2018

    @JohanLorenzo

    I got a similar error. I filed this issue in pytest pytest-dev/pytest#3747 (more details in there). @RonnyPfannschmidt suggested to open an issue over here. I put up a minimal test case https://github.com/JohanLorenzo/pytest-fixture-bug-3747. Please let me know if I can provide more details.

  5. RonnyPfannschmidt commented on Jul 31, 2018

    @RonnyPfannschmidt
    Member

    @jwldk fixture definition changed in pytest to give a deprecationwarning on non-fixture usage, this issue is a collateral of that

  6. nicoddemus commented on Aug 1, 2018

    @nicoddemus
    Member

    I investigated and here's the problem:

    @pytest.hookimpl(hookwrapper=True)
    def pytest_fixture_setup(fixturedef, request):
    """Adjust the event loop policy when an event loop is produced."""
    if isasyncgenfunction(fixturedef.func):
    # This is an async generator function. Wrap it accordingly.
    f = fixturedef.func

    In pytest 3.7.0 fixturef.func is the "wrapped" function (which issues the warning when calling directly), which is not a coroutine/async function. This of course breaks this code.

    @RonnyPfannschmidt unless we find a solution to this I'm considering reverting the wrapping code. pytest-asyncio probably is not the only plugin that will break because of this I'm afraid. 😟

  7. nicoddemus commented on Aug 1, 2018

    @nicoddemus
    Member

    Opened a tentative PR at pytest-dev/pytest#3754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions