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

Adds using to assert_num_queries #1170

Merged
merged 35 commits into from
Feb 10, 2025
Merged

Conversation

kingbuzzman
Copy link
Contributor

@kingbuzzman kingbuzzman commented Feb 7, 2025

Adds quality of life to replace

from django.db import connections

def test_test():
    with django_assert_num_queries(1, connection=connections["log"]):
        Model.objects.get()

with

def test_test():
    with django_assert_num_queries(1, using="log"):
        Model.objects.get()

I have multiple DBs and this is driving me nuts...

Copy link
Member

@adamchainz adamchainz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a valuable QOL and would actually align with Django’s API

docs/helpers.rst Outdated Show resolved Hide resolved
docs/helpers.rst Outdated Show resolved Hide resolved
pytest_django/fixtures.py Outdated Show resolved Hide resolved
pytest_django/fixtures.py Show resolved Hide resolved
pytest_django/fixtures.py Show resolved Hide resolved
docs/helpers.rst Outdated Show resolved Hide resolved
docs/helpers.rst Outdated Show resolved Hide resolved
docs/helpers.rst Outdated Show resolved Hide resolved
docs/helpers.rst Outdated Show resolved Hide resolved
pytest_django/fixtures.py Outdated Show resolved Hide resolved
kingbuzzman and others added 7 commits February 9, 2025 01:15
Co-authored-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
pytest_django/fixtures.py Outdated Show resolved Hide resolved
pytest_django/fixtures.py Outdated Show resolved Hide resolved
@kingbuzzman kingbuzzman marked this pull request as ready for review February 10, 2025 09:01
@kingbuzzman kingbuzzman mentioned this pull request Feb 10, 2025
bluetech pushed a commit that referenced this pull request Feb 10, 2025
This update addresses two common pain points when developing on GitHub.com's browser editor:

Delayed CI Testing: Small changes often accumulate, causing the CI to wait for all previous commits before testing your current commit. This delay can be inefficient. Suggestion: Cancel previous CI runs when pushing new commits to speed up the feedback loop.

Lack of Fix Suggestions for ruff Issues: When ruff flags an issue, it highlights the problematic code block but doesn't suggest how to fix it. By adding the --diff option, you can see the differences and get guidance on correcting the issue.

All this came about while working on #1170
Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

docs/changelog.rst Outdated Show resolved Hide resolved
@bluetech bluetech merged commit 0ee43ef into pytest-dev:main Feb 10, 2025
19 checks passed
@kingbuzzman kingbuzzman deleted the patch-1 branch February 10, 2025 12:57
@kingbuzzman
Copy link
Contributor Author

@bluetech thank you! Any idea when this will be released?

@bluetech
Copy link
Member

Soon!

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.

3 participants