Opened 5 years ago

Closed 5 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 Mariusz Felisiak, 5 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

Thanks for the report. Only template_name is used in ​documented calls, however it sounds reasonable to honor msg_prefix and count when these methods are used as context managers.

Would you like to provide a patch?

comment:2 by karyon, 5 years ago

Cc: karyon 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 Ad Timmering, 5 years ago

Owner: changed from nobody to Ad Timmering
Status: new → assigned

comment:4 by Ad Timmering, 5 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 Mariusz Felisiak, 5 years ago

Triage Stage: Accepted → Ready for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In e700a37:

Refs #33400 -- Renamed SimpleTestCase._assert_template_used() to _get_template_used().

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: → fixed
Status: assigned → closed

In 806efe91:

Fixed #33400 -- Added support for msg_prefix and count arguments to assertTemplateUsed()/assertTemplateNotUsed() used as context managers.

Note: See TracTickets for help on using tickets.
Back to Top