"""Djlint tests for ignored content. run: pytest tests/test_html/test_ignored.py --cov=src/djlint --cov-branch \ --cov-report xml:coverage.xml --cov-report term-missing pytest tests/test_html/test_ignored.py::test_ignored_block """ # pylint: disable=C0116 from typing import TextIO from click.testing import CliRunner from tests.conftest import reformat def test_ignored_block(runner: CliRunner, tmp_file: TextIO) -> None: output = reformat( tmp_file, runner, b"""

""", ) assert output.exit_code == 1 assert ( output.text == """

""" ) # check custom ignore tag {# djlint:off #} {# djlint:on #} output = reformat( tmp_file, runner, b"""

{# djlint:off #}

{# djlint:on #} {% comment %} djlint:off {% endcomment %}

{% comment %} djlint:on {% endcomment %} {{ /* djlint:off */ }}

{{ /* djlint:on */ }} {{!-- djlint:off --}}

{{!-- djlint:on --}} """, ) assert output.exit_code == 0 output = reformat( tmp_file, runner, b"""{# djlint: off #}{# djlint:on #} """, ) assert output.exit_code == 0 # check script tag output = reformat( tmp_file, runner, b""" """, ) assert output.exit_code == 0 assert ( """ """ in output.text ) # check inline script includes output = reformat( tmp_file, runner, b""" """, ) print(output.text) assert output.exit_code == 0 def test_style_tag(runner: CliRunner, tmp_file: TextIO) -> None: output = reformat( tmp_file, runner, b""" """, ) assert output.exit_code == 0 output = reformat( tmp_file, runner, b""" """, ) assert output.exit_code == 0 # check style includes output = reformat( tmp_file, runner, b"""""", ) assert output.exit_code == 0