| 240 | |
| 241 | def test_include_missing_template(self): |
| 242 | """ |
| 243 | Tests that the correct template is identified as not existing |
| 244 | when {% include %} specifies a template that does not exist. |
| 245 | """ |
| 246 | |
| 247 | # TEMPLATE_DEBUG must be true, otherwise the exception raised |
| 248 | # during {% include %} processing will be suppressed. |
| 249 | old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, True |
| 250 | old_loaders = loader.template_source_loaders |
| 251 | |
| 252 | try: |
| 253 | # Test the base loader class via the app loader. load_template |
| 254 | # from base is used by all shipped loaders excepting cached, |
| 255 | # which has its own test. |
| 256 | loader.template_source_loaders = (app_directories.Loader(),) |
| 257 | |
| 258 | load_name = 'test_include_error.html' |
| 259 | try: |
| 260 | tmpl = loader.select_template([load_name]) |
| 261 | r = None |
| 262 | r = tmpl.render(template.Context({})) |
| 263 | except template.TemplateDoesNotExist, e: |
| 264 | settings.TEMPLATE_DEBUG = old_td |
| 265 | self.assertEqual(e.args[0], 'missing.html') |
| 266 | self.assertEqual(r, None, 'Template rendering unexpectedly succeeded, produced: ->%r<-' % r) |
| 267 | finally: |
| 268 | loader.template_source_loaders = old_loaders |
| 269 | settings.TEMPLATE_DEBUG = old_td |
| 270 | |
| 271 | |