mirror of
https://github.com/Hopiu/djLint.git
synced 2026-03-23 08:40:24 +00:00
40 lines
1,008 B
Python
40 lines
1,008 B
Python
"""Djlint tests specific to django.
|
|
|
|
run::
|
|
|
|
pytest tests/test_django.py --cov=src/djlint --cov-branch \
|
|
--cov-report xml:coverage.xml --cov-report term-missing
|
|
|
|
for a single test, run::
|
|
|
|
pytest tests/test_django.py::test_alpine_js --cov=src/djlint \
|
|
--cov-branch --cov-report xml:coverage.xml --cov-report term-missing
|
|
|
|
"""
|
|
# pylint: disable=C0116
|
|
|
|
from typing import TextIO
|
|
|
|
from click.testing import CliRunner
|
|
|
|
from tests.conftest import reformat
|
|
|
|
|
|
def test_for_loop(runner: CliRunner, tmp_file: TextIO) -> None:
|
|
output = reformat(
|
|
tmp_file,
|
|
runner,
|
|
b"""<ul>{% for athlete in athlete_list %}<li>{{ athlete.name }}</li>{% empty %}<li>Sorry, no athletes in this list.</li>{% endfor %}</ul>""",
|
|
)
|
|
assert output.exit_code == 1
|
|
assert (
|
|
output.text
|
|
== r"""<ul>
|
|
{% for athlete in athlete_list %}
|
|
<li>{{ athlete.name }}</li>
|
|
{% empty %}
|
|
<li>Sorry, no athletes in this list.</li>
|
|
{% endfor %}
|
|
</ul>
|
|
"""
|
|
)
|