"""Djlint tests specific to django. run:: pytest tests/test_django/test_comments.py --cov=src/djlint --cov-branch \ --cov-report xml:coverage.xml --cov-report term-missing pytest tests/test_django/test_comments.py::test_nested_inline_comment """ # pylint: disable=C0116 from typing import TextIO from click.testing import CliRunner from tests.conftest import reformat def test_dj_comments_tag(runner: CliRunner, tmp_file: TextIO) -> None: output = reformat( tmp_file, runner, b"{# comment #}\n{% if this %}
{% endif %}" ) assert output.text == """{# comment #}\n{% if this %}{% endif %}\n""" # no change was required assert output.exit_code == 0 def test_comment(runner: CliRunner, tmp_file: TextIO) -> None: output = reformat( tmp_file, runner, b"""{% comment "Optional note" %}{{ body }}{% endcomment %}""" ) assert output.exit_code == 0 # too short to put on multiple lines assert ( output.text == r"""{% comment "Optional note" %}{{ body }}{% endcomment %} """ ) output = reformat( tmp_file, runner, b"""Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet
{# djlint:on #}