I am trying to find out the number of queries executed by a utility function. I have written a unit test for this function and the function is working well. What I would like to
If you are using pytest, pytest-django has django_assert_num_queries fixture for this purpose:
pytest
pytest-django
def test_queries(django_assert_num_queries): with django_assert_num_queries(3): Item.objects.create('foo') Item.objects.create('bar') Item.objects.create('baz')