def test(self, example): self.maxDiff = 5000 factory = RequestFactory() django = self.render_example( factory.get('/'), example, self.make_renderer('django', DjangoTemplates())) jinja2 = self.render_example(factory.get('/'), example, self.make_renderer('jinja2', Jinja2())) self.assertHTMLEqual( django, jinja2, 'renders of "{}" example must match'.format(example.basename))
def setUpClass(cls): cls.django_renderer = DjangoTemplates() cls.jinja2_renderer = Jinja2() if jinja2 else None cls.renderers = [cls.django_renderer] + ([cls.jinja2_renderer] if cls.jinja2_renderer else []) super().setUpClass()
from django.forms.renderers import DjangoTemplates, Jinja2 from django.test.html import parse_html from django.utils.datastructures import MultiValueDict from flexible_forms.utils import create_autocomplete_value, stable_json from flexible_forms.widgets import ( AutocompleteSelect, AutocompleteSelectMultiple, ) try: import jinja2 except ImportError: jinja2 = None _RENDERER = Jinja2() if jinja2 else DjangoTemplates() def check_html(widget, name, value, expected_html=None, attrs=None, **kwargs) -> bool: widget_html = widget.render(name, value, attrs=attrs, renderer=_RENDERER, **kwargs) if jinja2: