DON'T MERGE -- Add further tests for #19949. #1511

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
Member

ramiro commented Aug 25, 2013

No description provided.

@ArcTanSusan ArcTanSusan commented on the diff Aug 25, 2013

tests/template_tests/test_loaders.py
self.assertRaises(TemplateDoesNotExist, template_loader.load_template, "missing.html")
+ # Verify that the fact that the template hasn't been found has actually
+ # been cached:
+ self.assertTrue(template_loader.is_cached_notfoud("missing.html"))
@ArcTanSusan

ArcTanSusan Aug 25, 2013

Contributor

The unit test fails on L142. The quickfix for L142 is "self.assertTrue(TemplateDoesNotExist, template_loader.is_cached_notfoud("missing.html"))". Also, typo: "found" in comment.

@ramiro

ramiro Aug 25, 2013

Member

Yes, actually that failure was on purpose. It demonstrates we haven't fixed the bug and should help us to actually fix it.

It looks to me today that the is_cached_notfoud() method I added is overnegineered. Maybe we can simply remove it and replace the test with

self.assertEqual(template_loader.template_cache["missing.html"], TemplateDoesNotExist)

The intention was to avoid accessing the guts (template_cache) of the loader, but we are doing it above already.

@ArcTanSusan

ArcTanSusan Aug 26, 2013

Contributor

I added a 1-line fix in template/loaders/cached.py that pass all tests (and when removed, that last test fails).
Here it is:

L59 of cached.py:
self.template_cache[key] = TemplateDoesNotExist

See my PR on your PR: ramiro#1

@ArcTanSusan ArcTanSusan commented on the diff Aug 25, 2013

django/template/loaders/cached.py
@@ -79,3 +82,17 @@ def reset(self):
"Empty the template cache."
self.template_cache.clear()
self.find_template_cache.clear()
+
+ def inspect_cache(self, template_name, template_dirs=None):
+ """
+ Return the value stored in the cache for template_name.
+ Test instrumentation method.
+ """
+ key = self.cache_key(template_name, template_dirs)
+ return self.template_cache.get(key)
+
+ def is_cached_notfoud(self, template_name, template_dirs=None):
@ArcTanSusan

ArcTanSusan Aug 25, 2013

Contributor

Typo: "found".

Owner

timgraham commented Aug 27, 2013

merged in b785a80

Thanks for catching this.

timgraham closed this Aug 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment