#35571: TypeError in assertTemplateUsed when using pathlib.Path as template_name
-------------------------------------------+-------------------------------
               Reporter:  Erik Z.          |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Template system  |        Version:  5.0
               Severity:  Normal           |       Keywords:  template_name
           Triage Stage:  Unreviewed       |      Has patch:  1
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  1
                  UI/UX:  0                |
-------------------------------------------+-------------------------------
 Right now it is perfectly fine to use pathlib.Path as an template_name.
 This works fine for production as the template render fine. However when
 unit testing the assertTemplateUsed function throws a TypeError:

 {{{
 File "<stuff>/.local/lib/python3.12/site-
 packages/django/test/testcases.py", line 681, in _assert_template_used
         % (template_name, ", ".join(template_names)),
                           ^^^^^^^^^^^^^^^^^^^^^^^^^
     TypeError: sequence item 0: expected str instance, PosixPath found
 }}}

 This happens because the template_name is stored as is.

 Happened on 5.0.4
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35571>
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/010701906fec7564-cc533631-e8f8-4c1b-b87c-25ca31778130-000000%40eu-central-1.amazonses.com.

Reply via email to