mirror of
https://github.com/django-components/django-components.git
synced 2025-08-04 06:18:17 +00:00
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:
parent
8bbe81d717
commit
95f6554f4c
13 changed files with 3392 additions and 3339 deletions
|
@ -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 %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue