Skip to content

Async tests not supported #542

@brendan-morin

Description

@brendan-morin

Describe the issue
Async tests (e.g. pytest-asyncio) don't seem to be supported

To Reproduce
A basic example, from a django-ninja app with an async endpoint

@pytest.mark.asyncio
async def test_get(client: TestAsyncClient) -> None:
    brand = baker.make(Brand)
    ...

gives:

django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.

Expected behavior
It would be great to see this just work! Model bakery is possibly one of the best testing utility libraries I've ever used, and almost my exclusive reason to use django. It'd be great to see this work with the async endpoints.

Versions

  • Python: 3.12
  • Django 5.2.6
  • Model Bakery 1.20.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions