assertTemplateUsed() context manager crashes for templates without names.
When template_names includes at least one None type the string join will fail.
This occurs when a rendered template does not define a name.
Traceback (most recent call last):
File "/home/.../admin-frontend/admin_frontend/admin_cash/tests/test_views.py", line 19, in test_get_context_data
with self.assertTemplateUsed('admin_cash/bill_validator_logs.html'):
File "/home/../3.10/lib/python3.10/site-packages/django/test/testcases.py", line 146, in __exit__
self.test()
File "/home/../3.10/lib/python3.10/site-packages/django/test/testcases.py", line 131, in test
self.test_case._assert_template_used(
File "/home/../3.10/lib/python3.10/site-packages/django/test/testcases.py", line 828, in _assert_template_used
% (template_name, ", ".join(template_names)),
TypeError: sequence item 0: expected str instance, NoneType found
PR
Change History
(7)
Description: |
modified (diff)
|
Has patch: |
set
|
Needs tests: |
set
|
Owner: |
changed from nobody to Arian
|
Patch needs improvement: |
set
|
Status: |
new → assigned
|
Summary: |
_assert_template_used fails with anonymous templates → assertTemplateUsed() context manager crashes for templates without names.
|
Triage Stage: |
Unreviewed → Accepted
|
Description: |
modified (diff)
|
Needs tests: |
unset
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Suggested fix: https://github.com/django/django/pull/17237