mirror of https://github.com/django/django.git
Added tests for template's Engine.get_default().
This commit is contained in:
parent
7d1e237753
commit
7019724101
|
@ -1,8 +1,9 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.template import Context
|
from django.template import Context
|
||||||
from django.template.engine import Engine
|
from django.template.engine import Engine
|
||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase, override_settings
|
||||||
|
|
||||||
from .utils import ROOT, TEMPLATE_DIR
|
from .utils import ROOT, TEMPLATE_DIR
|
||||||
|
|
||||||
|
@ -21,6 +22,35 @@ class RenderToStringTest(SimpleTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class GetDefaultTests(SimpleTestCase):
|
||||||
|
|
||||||
|
@override_settings(TEMPLATES=[])
|
||||||
|
def test_no_engines_configured(self):
|
||||||
|
msg = 'No DjangoTemplates backend is configured.'
|
||||||
|
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||||
|
Engine.get_default()
|
||||||
|
|
||||||
|
@override_settings(TEMPLATES=[{
|
||||||
|
'NAME': 'default',
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
'OPTIONS': {'file_charset': 'abc'},
|
||||||
|
}])
|
||||||
|
def test_single_engine_configured(self):
|
||||||
|
self.assertEqual(Engine.get_default().file_charset, 'abc')
|
||||||
|
|
||||||
|
@override_settings(TEMPLATES=[{
|
||||||
|
'NAME': 'default',
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
}, {
|
||||||
|
'NAME': 'other',
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
}])
|
||||||
|
def test_multiple_engines_configured(self):
|
||||||
|
msg = 'Several DjangoTemplates backends are configured. You must select one explicitly.'
|
||||||
|
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||||
|
Engine.get_default()
|
||||||
|
|
||||||
|
|
||||||
class LoaderTests(SimpleTestCase):
|
class LoaderTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_origin(self):
|
def test_origin(self):
|
||||||
|
|
Loading…
Reference in New Issue