File: test_utils.py

package info (click to toggle)
python-django 1.8.18-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 41,628 kB
  • sloc: python: 189,488; xml: 695; makefile: 194; sh: 169; sql: 11
file content (46 lines) | stat: -rw-r--r-- 1,521 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from django.core.exceptions import ImproperlyConfigured
from django.template import engines
from django.test import SimpleTestCase, override_settings


class TemplateStringsTests(SimpleTestCase):

    @override_settings(TEMPLATES=[{
        'BACKEND': 'raise.import.error',
    }])
    def test_backend_import_error(self):
        """
        Failing to import a backend keeps raising the original import error.

        Regression test for #24265.
        """
        with self.assertRaises(ImportError):
            engines.all()
        with self.assertRaises(ImportError):
            engines.all()

    @override_settings(TEMPLATES=[{
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        # Incorrect: APP_DIRS and loaders are mutually incompatible.
        'APP_DIRS': True,
        'OPTIONS': {'loaders': []},
    }])
    def test_backend_improperly_configured(self):
        """
        Failing to initialize a backend keeps raising the original exception.

        Regression test for #24265.
        """
        with self.assertRaises(ImproperlyConfigured):
            engines.all()
        with self.assertRaises(ImproperlyConfigured):
            engines.all()

    @override_settings(TEMPLATES=[{
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
    }, {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
    }])
    def test_backend_names_must_be_unique(self):
        with self.assertRaises(ImproperlyConfigured):
            engines.all()