#34823: assertTemplateUsed() context manager crashes for templates without
names.
-----------------------------------+------------------------------------
Reporter: Arian | Owner: Arian
Type: Bug | Status: assigned
Component: Testing framework | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Arian):
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
Old description:
> 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
> }}}
New description:
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
}}}
[https://github.com/django/django/pull/17237 PR]
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34823#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018ab329bcb3-1a41d58e-eda3-48d6-abbb-546b026ebf57-000000%40eu-central-1.amazonses.com.