fixed #148, added test

This commit is contained in:
Christopher Pickering 2021-11-26 13:30:25 +01:00
parent 9fcf251ac5
commit 3281b55f61
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 8 additions and 3 deletions

View file

@ -209,8 +209,8 @@
exclude:
- django
patterns:
- <(?:/?(?:\w+)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*=([\"'])(?:(?!\1).)*?({%)[^-])\s*?(?:if|for|else|end)
- <(?:/?(?:\w+)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*=([\"'])(?:(?!\1).)*?{%(?:(?!%}).)*(?:if|else|for|end)(?:(?!%}).)*[^-](%}))
- <(?:/?(?:\w+)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*(?<!\bclass)=([\"'])(?:(?!\1).)*?({%)[^-])\s*?(?:if|for|else|end)
- <(?:/?(?:\w+)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}/])*(?<!\bclass)=([\"'])(?:(?!\1).)*?{%(?:(?!%}).)*(?:if|else|for|end)(?:(?!%}).)*[^-](%}))
- rule:
name: H029
message: Consider using lowercase form method values.

View file

@ -7,7 +7,7 @@ run::
# for a single test
pytest tests/test_linter.py::test_H025 --cov=src/djlint --cov-branch \
pytest tests/test_linter.py::test_T028 --cov=src/djlint --cov-branch \
--cov-report xml:coverage.xml --cov-report term-missing
"""
@ -520,6 +520,11 @@ def test_T028(runner: CliRunner, tmp_file: TextIO) -> None:
result = runner.invoke(djlint, [tmp_file.name])
assert "T028" not in result.output
# class should not trigger
write_to_file(tmp_file.name, b'<input class="{% if %}{% endif %}" />')
result = runner.invoke(djlint, [tmp_file.name])
assert "T028" not in result.output
def test_H029(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(tmp_file.name, b'<forM method="Post">')