Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pattern argument to django_assert_num_queries fixture #1040

Conversation

qarlosh
Copy link

@qarlosh qarlosh commented Dec 16, 2022

This optional argument allows to filter the queries to take into account for the assertion.

It may be useful to check for the count of only certain queries. For example, a use case of mine is to skip SAVEPOINT queries by using:

NO_SAVEPOINT_PATTERN=r'(?!^(ROLLBACK TO |RELEASE )?SAVEPOINT [`"].+[`"]$)'
...
with django_assert_num_queries(n, pattern=NO_SAVEPOINT_PATTERN):
   ...

This optional arguments allows to filter the queries to take into account for the assertion
@bluetech
Copy link
Member

It will be better to propose this change to Django's version first.

@bluetech bluetech closed this Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants