Skip to content

No event loop in the thread 'MainThread' when using test_client fixture #1069

Closed
@argaen

Description

@argaen

Long story short

When using the test_client pytest fixture and calling other functions that make use of the get_event_loop function internally like for example asyncio.Task.current_task() it raises the RuntimeError: There is no current event loop in thread 'MainThread' exception.

This forces the user to pass the loop explicitly to all calls but we are forcing the user to:

  1. Modify the code in order to support testing with it
  2. Passing explicitly the loop to all calls that need it which is not always possible because the request object is not propagated to all the code.

Expected behaviour

Normal calls that require a loop should work without needing to pass the loop explicitly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions