-
Notifications
You must be signed in to change notification settings - Fork 341
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
Idea: Ability to capture queries but not fail the test #1034
Comments
pytest-django uses Django's As for my own opinion, I think this usecase is a bit too niche to be worth the extra mental overhead. You can implement such a fixture yourself in a local If you implement this, make sure to post the snippet here for anyone else who might want this :) |
Let's say we've got a following test:
This test would pass of course just fine.
Let's say For some reason I remove the line
PostHistory.objects.create(post=post)
.Now the test fails with the number of queries being incorrect (1 instead of 2). But in order to debug this using the following test, I'd have to either comment out the num_queries assertion, or have a separate test for just testing the query count, but that's a solution we don't really want, as there'll always be a test case that tests the logic, but doesn't really check if the queries match (you could have n-queries inside if-statement for example).
As a potential solution for this I was thinking of having a way to not fail the test (only for development), but rather only display the message as a warning.
I think ideally, we could add a CLI flag in the lines of
--no-fail-on-django-query-count
or something similar.I'm happy to work on this, just wanted to see if there's any interest in adding something like that, or if there's a better solution to this issue.
The text was updated successfully, but these errors were encountered: