mirror of
https://github.com/django-components/django-components.git
synced 2025-11-13 12:21:53 +00:00
Merge branch 'master' into feat/auto-public
This commit is contained in:
commit
5afe5f0578
1 changed files with 43 additions and 1 deletions
|
|
@ -10,7 +10,7 @@ from typing import Any, List, Literal, NamedTuple, Optional
|
|||
import pytest
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.template import Context, RequestContext, Template
|
||||
from django.template import Context, RequestContext, Template, TemplateSyntaxError
|
||||
from django.template.base import TextNode
|
||||
from django.test import Client
|
||||
from django.urls import path
|
||||
|
|
@ -1471,6 +1471,48 @@ class TestComponentRender:
|
|||
):
|
||||
Root.render()
|
||||
|
||||
@djc_test(parametrize=PARAMETRIZE_CONTEXT_BEHAVIOR)
|
||||
def test_prepends_exceptions_on_template_compile_error(self, components_settings):
|
||||
@register("simple_component")
|
||||
class SimpleComponent(Component):
|
||||
template = "hello"
|
||||
|
||||
class Other(Component):
|
||||
template = """
|
||||
{% load component_tags %}
|
||||
{% component "simple_component" %}
|
||||
{% endif %}
|
||||
"""
|
||||
|
||||
with pytest.raises(
|
||||
TemplateSyntaxError,
|
||||
match=re.escape(
|
||||
"An error occured while rendering components Other:\n"
|
||||
"Invalid block tag on line 4: 'endif', expected 'endcomponent'",
|
||||
),
|
||||
):
|
||||
Other.render()
|
||||
|
||||
@djc_test(parametrize=PARAMETRIZE_CONTEXT_BEHAVIOR)
|
||||
def test_prepends_exceptions_on_template_compile_error2(self, components_settings):
|
||||
@register("simple_component")
|
||||
class SimpleComponent(Component):
|
||||
template = "hello"
|
||||
|
||||
class Other(Component):
|
||||
template = """
|
||||
{% load component_tags %}
|
||||
{% component "simple_component" %}
|
||||
"""
|
||||
|
||||
with pytest.raises(
|
||||
TemplateSyntaxError,
|
||||
match=re.escape(
|
||||
"An error occured while rendering components Other:\nUnclosed tag on line 3: 'component'",
|
||||
),
|
||||
):
|
||||
Other.render()
|
||||
|
||||
@djc_test(parametrize=PARAMETRIZE_CONTEXT_BEHAVIOR)
|
||||
def test_pydantic_exception(self, components_settings):
|
||||
from pydantic import BaseModel, ValidationError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue