diff options
| author | django-bot <ops@djangoproject.com> | 2022-02-03 20:24:19 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-07 20:37:05 +0100 |
| commit | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch) | |
| tree | f0506b668a013d0063e5fba3dbf4863b466713ba /tests/template_tests/test_extends_relative.py | |
| parent | f68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff) | |
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/template_tests/test_extends_relative.py')
| -rw-r--r-- | tests/template_tests/test_extends_relative.py | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/tests/template_tests/test_extends_relative.py b/tests/template_tests/test_extends_relative.py index 49a7624600..b20b0150d4 100644 --- a/tests/template_tests/test_extends_relative.py +++ b/tests/template_tests/test_extends_relative.py @@ -5,52 +5,51 @@ from django.test import SimpleTestCase from .utils import ROOT -RELATIVE = os.path.join(ROOT, 'relative_templates') +RELATIVE = os.path.join(ROOT, "relative_templates") class ExtendsRelativeBehaviorTests(SimpleTestCase): - def test_normal_extend(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('one.html') + template = engine.get_template("one.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'three two one') + self.assertEqual(output.strip(), "three two one") def test_normal_extend_variable(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('one_var.html') - output = template.render(Context({'tmpl': './two.html'})) - self.assertEqual(output.strip(), 'three two one') + template = engine.get_template("one_var.html") + output = template.render(Context({"tmpl": "./two.html"})) + self.assertEqual(output.strip(), "three two one") def test_dir1_extend(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/one.html') + template = engine.get_template("dir1/one.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'three two one dir1 one') + self.assertEqual(output.strip(), "three two one dir1 one") def test_dir1_extend1(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/one1.html') + template = engine.get_template("dir1/one1.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'three two one dir1 one') + self.assertEqual(output.strip(), "three two one dir1 one") def test_dir1_extend2(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/one2.html') + template = engine.get_template("dir1/one2.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'three two one dir1 one') + self.assertEqual(output.strip(), "three two one dir1 one") def test_dir1_extend3(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/one3.html') + template = engine.get_template("dir1/one3.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'three two one dir1 one') + self.assertEqual(output.strip(), "three two one dir1 one") def test_dir2_extend(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/dir2/one.html') + template = engine.get_template("dir1/dir2/one.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'three two one dir2 one') + self.assertEqual(output.strip(), "three two one dir2 one") def test_extend_error(self): engine = Engine(dirs=[RELATIVE]) @@ -59,28 +58,27 @@ class ExtendsRelativeBehaviorTests(SimpleTestCase): "hierarchy that template 'error_extends.html' is in." ) with self.assertRaisesMessage(TemplateSyntaxError, msg): - engine.render_to_string('error_extends.html') + engine.render_to_string("error_extends.html") class IncludeRelativeBehaviorTests(SimpleTestCase): - def test_normal_include(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/dir2/inc2.html') + template = engine.get_template("dir1/dir2/inc2.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'dir2 include') + self.assertEqual(output.strip(), "dir2 include") def test_normal_include_variable(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/dir2/inc3.html') - output = template.render(Context({'tmpl': './include_content.html'})) - self.assertEqual(output.strip(), 'dir2 include') + template = engine.get_template("dir1/dir2/inc3.html") + output = template.render(Context({"tmpl": "./include_content.html"})) + self.assertEqual(output.strip(), "dir2 include") def test_dir2_include(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/dir2/inc1.html') + template = engine.get_template("dir1/dir2/inc1.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'three') + self.assertEqual(output.strip(), "three") def test_include_error(self): engine = Engine(dirs=[RELATIVE]) @@ -89,29 +87,28 @@ class IncludeRelativeBehaviorTests(SimpleTestCase): "hierarchy that template 'error_include.html' is in." ) with self.assertRaisesMessage(TemplateSyntaxError, msg): - engine.render_to_string('error_include.html') + engine.render_to_string("error_include.html") class ExtendsMixedBehaviorTests(SimpleTestCase): - def test_mixing1(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/two.html') + template = engine.get_template("dir1/two.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'three two one dir2 one dir1 two') + self.assertEqual(output.strip(), "three two one dir2 one dir1 two") def test_mixing2(self): engine = Engine(dirs=[RELATIVE]) - template = engine.get_template('dir1/three.html') + template = engine.get_template("dir1/three.html") output = template.render(Context({})) - self.assertEqual(output.strip(), 'three dir1 three') + self.assertEqual(output.strip(), "three dir1 three") def test_mixing_loop(self): engine = Engine(dirs=[RELATIVE]) msg = ( "The relative path '\"./dir2/../looped.html\"' was translated to " - "template name \'dir1/looped.html\', the same template in which " + "template name 'dir1/looped.html', the same template in which " "the tag appears." ) with self.assertRaisesMessage(TemplateSyntaxError, msg): - engine.render_to_string('dir1/looped.html') + engine.render_to_string("dir1/looped.html") |
