mirror of
https://github.com/django-components/django-components.git
synced 2025-11-07 01:56:42 +00:00
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
29 lines
828 B
Python
29 lines
828 B
Python
import pytest
|
|
from django.template import Context, Template
|
|
|
|
from django_components import registry, types
|
|
from django_components.testing import djc_test
|
|
|
|
|
|
def _import_components():
|
|
from docs.examples.recursion.component import Recursion # noqa: PLC0415
|
|
|
|
registry.register("recursion", Recursion)
|
|
|
|
|
|
@pytest.mark.django_db
|
|
@djc_test
|
|
class TestRecursion:
|
|
def test_renders_recursively(self):
|
|
_import_components()
|
|
|
|
template_str: types.django_html = """
|
|
{% load component_tags %}
|
|
{% component "recursion" / %}
|
|
"""
|
|
template = Template(template_str)
|
|
rendered = template.render(Context({}))
|
|
|
|
# Expect 101 levels of depth (0 to 100)
|
|
assert rendered.count("Recursion depth:") == 100
|
|
assert "Reached maximum recursion depth!" in rendered
|