Skip to content

Warn when an async function is executed without an appropriate plugin #4814

Closed
@crusaderky

Description

@crusaderky

In the following code:

async def test1():
    assert Fail

@pytest.mark.asyncio
async def test2():
    assert Fail
  • test1 is silently skipped and marked as successful.
  • test2 follows the same fate if pytest-asyncio is not installed.

Both use cases can be very easily triggered by distraction in real life; the sensible behaviour should be that both tests fail no matter what:

  • Using the @pytest.mark.asyncio decorator without pytest-asyncio installed should cause an error
  • An error should be raised if a test function returns a coroutine

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: reportingrelated to terminal output and user-facing messages and errorstype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions