summaryrefslogtreecommitdiff
path: root/tests/template_tests/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/template_tests/utils.py')
-rw-r--r--tests/template_tests/utils.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/tests/template_tests/utils.py b/tests/template_tests/utils.py
index ad77eae1dd..2e78ec9894 100644
--- a/tests/template_tests/utils.py
+++ b/tests/template_tests/utils.py
@@ -6,7 +6,7 @@ from django.test.utils import override_settings
from django.utils.safestring import mark_safe
ROOT = os.path.dirname(os.path.abspath(__file__))
-TEMPLATE_DIR = os.path.join(ROOT, 'templates')
+TEMPLATE_DIR = os.path.join(ROOT, "templates")
def setup(templates, *args, test_once=False):
@@ -34,9 +34,12 @@ def setup(templates, *args, test_once=False):
templates["inclusion.html"] = "{{ result }}"
loaders = [
- ('django.template.loaders.cached.Loader', [
- ('django.template.loaders.locmem.Loader', templates),
- ]),
+ (
+ "django.template.loaders.cached.Loader",
+ [
+ ("django.template.loaders.locmem.Loader", templates),
+ ],
+ ),
]
def decorator(func):
@@ -46,7 +49,7 @@ def setup(templates, *args, test_once=False):
@functools.wraps(func)
def inner(self):
# Set up custom template tag libraries if specified
- libraries = getattr(self, 'libraries', {})
+ libraries = getattr(self, "libraries", {})
self.engine = Engine(
libraries=libraries,
@@ -60,7 +63,7 @@ def setup(templates, *args, test_once=False):
self.engine = Engine(
libraries=libraries,
loaders=loaders,
- string_if_invalid='INVALID',
+ string_if_invalid="INVALID",
)
func(self)
func(self)
@@ -98,7 +101,7 @@ class SomeClass:
self.otherclass = OtherClass()
def method(self):
- return 'SomeClass.method'
+ return "SomeClass.method"
def method2(self, o):
return o
@@ -113,9 +116,9 @@ class SomeClass:
raise TypeError
def __getitem__(self, key):
- if key == 'silent_fail_key':
+ if key == "silent_fail_key":
raise SomeException
- elif key == 'noisy_fail_key':
+ elif key == "noisy_fail_key":
raise SomeOtherException
raise KeyError
@@ -138,7 +141,7 @@ class SomeClass:
class OtherClass:
def method(self):
- return 'OtherClass.method'
+ return "OtherClass.method"
class TestObj:
@@ -160,21 +163,23 @@ class SilentGetItemClass:
class SilentAttrClass:
def b(self):
raise SomeException
+
b = property(b)
class UTF8Class:
"Class whose __str__ returns non-ASCII data"
+
def __str__(self):
- return 'ŠĐĆŽćžšđ'
+ return "ŠĐĆŽćžšđ"
# These two classes are used to test auto-escaping of string output.
class UnsafeClass:
def __str__(self):
- return 'you & me'
+ return "you & me"
class SafeClass:
def __str__(self):
- return mark_safe('you > me')
+ return mark_safe("you > me")