Skip to content

Commit

Permalink
Added tests for template's Engine.get_default().
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlton Gibson authored and timgraham committed Mar 31, 2017
1 parent 7d1e237 commit 7019724
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion tests/template_tests/test_engine.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

from django.core.exceptions import ImproperlyConfigured
from django.template import Context
from django.template.engine import Engine
from django.test import SimpleTestCase
from django.test import SimpleTestCase, override_settings

from .utils import ROOT, TEMPLATE_DIR

Expand All @@ -21,6 +22,35 @@ def test_basic_context(self):
)


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):

def test_origin(self):
Expand Down

0 comments on commit 7019724

Please sign in to comment.