Opened 15 months ago

Last modified 14 months ago

#34823 closed Bug

_assert_template_used fails with anonymous templates — at Version 2

Reported by: Arian Owned by: nobody
Component: Testing framework Version: 4.2
Severity: Normal Keywords:
Cc: 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 (last modified by Arian)

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

Change History (2)

comment:2 by Arian, 15 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top