diff options
| author | Preston Timmons <prestontimmons@gmail.com> | 2015-02-24 09:17:17 -0600 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-03-02 07:53:58 -0500 |
| commit | 80d6b6b863109cfb60a7fcc5936136e347ecd57a (patch) | |
| tree | 8858dfe6363807d0c2dd5ec571d452d15a8dad85 /tests | |
| parent | 4b8979e477a5315f3dfde0348393fd404fb70ee4 (diff) | |
Fixed #24409 -- Combined the app_directories and filesystem loader implementation.
Besides the directories they look in, these two loaders are functionally
the same. This removes unnecessary code duplication between the two.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/template_tests/test_loaders.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/template_tests/test_loaders.py b/tests/template_tests/test_loaders.py index 5eb4f64cea..059e37ed3c 100644 --- a/tests/template_tests/test_loaders.py +++ b/tests/template_tests/test_loaders.py @@ -185,11 +185,16 @@ class FileSystemLoaderTests(SimpleTestCase): def check_sources(path, expected_sources): expected_sources = [os.path.abspath(s) for s in expected_sources] self.assertEqual( - list(loader.get_template_sources(path, dirs)), + list(loader.get_template_sources(path)), expected_sources, ) - yield check_sources + original_dirs = self.engine.dirs + self.engine.dirs = dirs + try: + yield check_sources + finally: + self.engine.dirs = original_dirs def test_directory_security(self): with self.source_checker(['/dir1', '/dir2']) as check_sources: @@ -234,9 +239,18 @@ class FileSystemLoaderTests(SimpleTestCase): check_sources('/DIR1/index.HTML', ['/DIR1/index.HTML']) -class AppDirectoriesLoaderTest(FileSystemLoaderTests): +class AppDirectoriesLoaderTest(SimpleTestCase): def setUp(self): self.engine = Engine( loaders=['django.template.loaders.app_directories.Loader'], ) + + @override_settings(INSTALLED_APPS=['template_tests']) + def test_load_template(self): + self.engine.get_template('index.html') + + @override_settings(INSTALLED_APPS=[]) + def test_not_installed(self): + with self.assertRaises(TemplateDoesNotExist): + self.engine.get_template('index.html') |
