tests: Split test files and run template tests under both context behavior modes (#509)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Juro Oravec 2024-05-28 08:23:32 +02:00 committed by GitHub
parent 8bbe81d717
commit 95f6554f4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 3392 additions and 3339 deletions

View file

@ -3,7 +3,7 @@ from django.template.base import Parser
# isort: off
from .django_test_setup import * # NOQA
from .testutils import BaseTestCase
from .testutils import BaseTestCase, parametrize_context_behavior
# isort: on
@ -56,21 +56,23 @@ class ParserTest(BaseTestCase):
class ParserComponentTest(BaseTestCase):
def test_special_chars_accessible_via_kwargs(self):
@component.register(name="test")
class SimpleComponent(component.Component):
template: types.django_html = """
{{ date }}
{{ id }}
{{ on_click }}
"""
class SimpleComponent(component.Component):
template: types.django_html = """
{{ date }}
{{ id }}
{{ on_click }}
"""
def get_context_data(self, **kwargs):
return {
"date": kwargs["my-date"],
"id": kwargs["#some_id"],
"on_click": kwargs["@click.native"],
}
def get_context_data(self, **kwargs):
return {
"date": kwargs["my-date"],
"id": kwargs["#some_id"],
"on_click": kwargs["@click.native"],
}
@parametrize_context_behavior(["django", "isolated"])
def test_special_chars_accessible_via_kwargs(self):
component.registry.register("test", self.SimpleComponent)
template_str: types.django_html = """
{% load component_tags %}