#24094 closed Bug (fixed)
Unable to run a subset of template tests
Reported by: | Tim Graham | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
./runtests.py template_tests.syntax_tests
fails with RemovedInDjango20Warning
on 9 of the tests complaining that "You haven't defined a TEMPLATES setting".
Change History (8)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
I took a look at this. I didn't find the exact issue, but I noticed a few things:
- The tests that fail all have "{% load custom %}".
- The tags that cause the problem are inclusion tags that have a "get_template" call in the decorator. Removing these removes the warnings.
- I think there is a side-effect when template_tests.test_loaders is imported by unittest discovery.
The tests pass with this command:
./runtests.py template_tests.test_loaders template_tests.syntax_tests
But fail in reverse:
./runtests.py template_tests.test_loaders template_tests.syntax_tests --reverse
comment:4 by , 10 years ago
More specifically, a side-effect seems to appear in template_tests.test_loaders.DeprecatedRenderToStringTest.test_no_empty_dict_push_to_stack. The syntax_tests fail when run in combination with test_loaders if that method is removed.
comment:5 by , 10 years ago
I added a pull request for this. It fixes the problem by moving inclusion tags from template_tests.templatetags.custom
into their own module, template_tests.templatetags.inclusion
.
The warnings were masked before because template_tests.test_loaders.DeprecatedRenderToStringTest.test_no_empty_dict_pushed_to_stack
uses a template that runs {% load custom %}
. Since the get_template
calls are evaluated at import time, no warning was raised when template_tests.syntax_tests
later loaded that file.
Since the syntax_tests
don't use the inclusion tags, the tests now run isolated from any global settings.
comment:6 by , 10 years ago
Has patch: | set |
---|
comment:7 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I can reproduce this.
I understand why these tests fail -- they run isolated from Django settings, and to make sure they don't accidentally use a globally configured
DjangoTemplates
engine,TEMPLATES
is set toNone
for these tests.What I fail to understand is why they pass when not run in isolation e.g.
./runtests.py template_tests
. Perhaps I missed some cases when handling thesetting_changed
signal.