2022-02-18 20:15:36 +00:00
|
|
|
"""Djlint tests specific to .djlintrc configuration.
|
|
|
|
|
|
|
|
|
|
run::
|
|
|
|
|
|
2022-05-16 14:25:29 +00:00
|
|
|
pytest tests/test_config/test_json/test_config.py --cov=src/djlint --cov-branch \
|
2022-02-18 20:15:36 +00:00
|
|
|
--cov-report xml:coverage.xml --cov-report term-missing
|
|
|
|
|
|
2022-09-07 18:10:13 +00:00
|
|
|
pytest tests/test_config/test_json/test_config.py::test_custom_config
|
2022-02-18 20:15:36 +00:00
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
# pylint: disable=C0116
|
|
|
|
|
|
|
|
|
|
from click.testing import CliRunner
|
|
|
|
|
|
|
|
|
|
from src.djlint import main as djlint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_config(runner: CliRunner) -> None:
|
2022-05-13 20:36:55 +00:00
|
|
|
result = runner.invoke(djlint, ["tests/test_config/test_json/html.html", "--check"])
|
2022-02-18 20:15:36 +00:00
|
|
|
|
|
|
|
|
assert (
|
|
|
|
|
"""-{% example stuff %}<p>this is a long paragraph</p>{% endexample %}
|
|
|
|
|
+{% example stuff %}
|
2022-10-12 07:29:31 +00:00
|
|
|
+ <p>this is a long paragraph</p>
|
2022-02-18 20:15:36 +00:00
|
|
|
+{% endexample %}
|
|
|
|
|
"""
|
|
|
|
|
in result.output
|
|
|
|
|
)
|
|
|
|
|
assert result.exit_code == 1
|
2022-09-07 18:10:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_custom_config(runner: CliRunner) -> None:
|
|
|
|
|
result = runner.invoke(
|
|
|
|
|
djlint,
|
|
|
|
|
[
|
|
|
|
|
"tests/test_config/test_json/html.html",
|
|
|
|
|
"--check",
|
|
|
|
|
"--configuration",
|
|
|
|
|
"tests/test_config/test_json/.djlint-cust",
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
assert (
|
|
|
|
|
"""-{% example stuff %}<p>this is a long paragraph</p>{% endexample %}
|
|
|
|
|
+{% example stuff %}
|
|
|
|
|
+ <p>this is a long paragraph</p>
|
|
|
|
|
+{% endexample %}
|
|
|
|
|
"""
|
|
|
|
|
in result.output
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert result.exit_code == 1
|