[2.2.x] Reverted "Fixed forms_tests.tests.test_renderers with Jinja 3.1.0+."

This reverts commit 1d9d082acf.
Backport of abfdb4d7f3 from main
This commit is contained in:
Mariusz Felisiak 2022-03-26 12:27:30 +01:00
parent e03648f09c
commit 2801f29dad
1 changed files with 0 additions and 24 deletions

View File

@ -1,12 +1,10 @@
import os import os
import posixpath
import unittest import unittest
from django.forms.renderers import ( from django.forms.renderers import (
BaseRenderer, DjangoTemplates, Jinja2, TemplatesSetting, BaseRenderer, DjangoTemplates, Jinja2, TemplatesSetting,
) )
from django.test import SimpleTestCase from django.test import SimpleTestCase
from django.utils.version import get_version_tuple
try: try:
import jinja2 import jinja2
@ -48,28 +46,6 @@ class Jinja2Tests(SharedTests, SimpleTestCase):
renderer = Jinja2 renderer = Jinja2
expected_widget_dir = 'jinja2' expected_widget_dir = 'jinja2'
@property
def jinja2_version(self):
return get_version_tuple(jinja2.__version__)
def test_installed_apps_template_found(self):
"""Can find a custom template in INSTALLED_APPS."""
renderer = self.renderer()
# Found because forms_tests is .
tpl = renderer.get_template("forms_tests/custom_widget.html")
expected_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", self.expected_widget_dir)
)
if self.jinja2_version < (3, 1):
expected_path = os.path.join(
expected_path, "forms_tests", "custom_widget.html"
)
else:
expected_path = posixpath.join(
expected_path, "forms_tests", "custom_widget.html"
)
self.assertEqual(tpl.origin.name, expected_path)
class TemplatesSettingTests(SharedTests, SimpleTestCase): class TemplatesSettingTests(SharedTests, SimpleTestCase):
renderer = TemplatesSetting renderer = TemplatesSetting