-
Notifications
You must be signed in to change notification settings - Fork 346
Add fixture for asserting maximum number of database queries #547
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
Conversation
Please rebase, since our tests in master were failing with pytest 3.3. |
fcacbe0
to
2bf9f3b
Compare
Codecov Report
@@ Coverage Diff @@
## master #547 +/- ##
==========================================
+ Coverage 92.33% 92.42% +0.08%
==========================================
Files 32 32
Lines 1710 1742 +32
Branches 142 143 +1
==========================================
+ Hits 1579 1610 +31
- Misses 94 95 +1
Partials 37 37
Continue to review full report at Codecov.
|
@blueyed I did a rebase and the tests are now passing. |
@lukaszb |
I'd leave previous name - it might be less strict but it's how Django named their test method and I'm for consistency here. Other than that I don't see anything wrong with |
2bf9f3b
to
36a0f5d
Compare
@blueyed There you go! |
bb984c7
to
f132019
Compare
Rebased and fixed a warning reported by Sphinx. |
Extended it a bit to return the wrapped context manager, and added support for |
Looks very good to me! |
Thank you, merged! |
Often I don't want to test against the exact number of queries performed by a particular piece of code but just be sure that changes to the codebase don't end up in an unnoticed excessive increase of queries.
django-test-plus has a really nice helper for this kind of scenario: https://github.com/revsys/django-test-plus#assertnumquerieslessthannumber---context
This PR tries to port the same functionality to
pytest-django
.Open issues:
assert_num_queries
toassert_exact_num_queries
make sense?Cheers,
Andreas