Opened 3 years ago
Closed 3 years ago
#33400 closed Bug (fixed)
assertTemplateUsed()/assertTemplateNotUsed() used as context managers ignore count and msg_prefix parameters.
Reported by: | karyon | Owned by: | Ad Timmering |
---|---|---|---|
Component: | Testing framework | Version: | 4.0 |
Severity: | Normal | Keywords: | |
Cc: | karyon | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
See the code of assertTemplateUsed: if it's used as a context manager, the count parameter is entirely unused. The documentation on assertTemplateUsed does not mention that.
The context manager capability was added in a678e9ea65 10 years ago. The count parameter was added in 17c188445 8 years ago.
Change History (7)
comment:1 by , 3 years ago
Summary: | assertTemplateUsed as context manager does not respect count parameter → assertTemplateUsed()/assertTemplateNotUsed() used as context managers ignore count and msg_prefix parameters. |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 3 years ago
Cc: | added |
---|
I could add a note to the documentation, but I don't have the capacity for properly making this work, sorry.
comment:3 by , 3 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 3 years ago
Has patch: | set |
---|
Gave it a shot in PR, in the process aligning error messages to be for context manager use and direct call use. Comments welcome and appreciated.
comment:5 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Thanks for the report. Only
template_name
is used in documented calls, however it sounds reasonable to honormsg_prefix
andcount
when these methods are used as context managers.Would you like to provide a patch?