Skip to content

Add overloads for assertTemplateUsed and assertTemplateNotUsed - #3564

Open
brianhelba wants to merge 1 commit into
typeddjango:masterfrom
brianhelba:template-used
Open

Add overloads for assertTemplateUsed and assertTemplateNotUsed#3564
brianhelba wants to merge 1 commit into
typeddjango:masterfrom
brianhelba:template-used

Conversation

@brianhelba

Copy link
Copy Markdown
Contributor

The return type of these can actually be determined more precisely, given the argument types.

Follows https://github.com/pytest-dev/pytest-django/pull/12781

AI Policy

  • I have read and agree to the AI Policy, removed any "Co-Authored-By" lines attributing coding agents, and manually reviewed the final result

The return type of these can actually be
determined more precisely, given the argument types.

Follows https://github.com/pytest-dev/pytest-django/pull/12781
def test_assert_template_used(self) -> None:
response = self.client.get("/url")
assert_type(self.assertTemplateUsed(response, "template.html"), None)
assert_type(self.assertTemplateUsed("template.html"), _AssertTemplateUsedContext)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would better be:

with self.assertTemplateUsed("template.html") as ctx:
    assert_type(ctx, ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants