django-components/docs/examples/recursion/test_example_recursive.py
Juro Oravec 49afdb49d6
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
docs: Add "scenarios" code examples (#1445)
2025-10-08 00:17:31 +02:00

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