pytest-django icon indicating copy to clipboard operation
pytest-django copied to clipboard

Updating django to 4.2.1 makes django_assert_num_queries not see queries

Open MuslimBeibytuly opened this issue 2 years ago • 1 comments

docker image: python:3.11.2-slim
django==4.2.1
pytest-django==4.5.2
    with django_assert_num_queries(num=1):
        response = authenticated_client.get(
            path='/api/endpoint_name/',
        )

shows: Failed: Expected to perform 1 queries but 0 were done while endpoint has 1 query, it was shown using django 4.2 version

MuslimBeibytuly avatar May 31 '23 09:05 MuslimBeibytuly

Still broken with:

platform darwin -- Python 3.11.1, pytest-7.4.0, pluggy-1.3.0
plugins: anyio-4.0.0, xdist-3.3.1, kolo-2.14.0, django-4.5.2, Faker-19.3.1

and

django==4.2.5

when using python-xdist (pytest -n2 pat/to/test).

The behavior is flaky, sometimes the test passes, sometimes not. I can see the SQL queries in the logs but django_assert_num_queries captures zero queries.

elnygren avatar Sep 29 '23 07:09 elnygren