diff --git a/pyproject.toml b/pyproject.toml index ca6856ba5..2a25c7e7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,7 +85,7 @@ select = [ "W", ] target-version = "py311" -ignore = ["E501", "PLR0913", "PLR0915", "PLR0912", "D203", "D213"] +ignore = ["E501", "PLR0913", "PLR0915", "PLR0912", "D203", "D213", "PLW1510"] [tool.ruff.per-file-ignores] "tests/*" = ["N802", "D103", "T201", "D104", "PLR0915", "PLR2004"] diff --git a/tests/test_linter/test_h033.py b/tests/test_linter/test_h033.py new file mode 100644 index 000000000..7761703aa --- /dev/null +++ b/tests/test_linter/test_h033.py @@ -0,0 +1,162 @@ +"""Test form action tags. + +poetry run pytest tests/test_linter/test_h033.py +""" +import pytest + +from src.djlint.lint import linter +from tests.conftest import lint_printer + +test_data = [ + pytest.param( + ("
...
"), + ( + [ + { + "code": "H033", + "line": "1:0", + "match": '
...
"), + ([]), + id="one - no error", + ), + pytest.param( + ("
...
"), + ( + [ + { + "code": "H033", + "line": "1:0", + "match": '
...
"), + ([]), + id="two - no error", + ), + pytest.param( + ("
...
"), + ( + [ + { + "code": "H033", + "line": "1:0", + "match": '
...
'), + ( + [ + { + "code": "H033", + "line": "1:0", + "match": '
...
"), + ( + [ + { + "code": "H033", + "line": "1:0", + "match": '
...
'), + ( + [ + { + "code": "H033", + "line": "1:0", + "match": '
...
'), + ([]), + id="six - no error", + ), + pytest.param( + ( + '
\n' + " \n" + "
" + ), + ([]), + id="gh pr #743", + ), +] + + +@pytest.mark.parametrize(("source", "expected"), test_data) +def test_base(source, expected, basic_config): + filename = "test.html" + output = linter(basic_config, source, filename, filename) + + lint_printer(source, expected, output[filename]) + + mismatch = list(filter(lambda x: x not in expected, output[filename])) + list( + filter(lambda x: x not in output[filename], expected) + ) + + assert len(mismatch) == 0 diff --git a/tests/test_linter/test_linter.py b/tests/test_linter/test_linter.py index a9c6ce922..39f302872 100644 --- a/tests/test_linter/test_linter.py +++ b/tests/test_linter/test_linter.py @@ -438,45 +438,6 @@ def test_H031(runner: CliRunner, tmp_file: TextIO) -> None: assert "H031" not in result.output -def test_H033(runner: CliRunner, tmp_file: TextIO) -> None: - write_to_file( - tmp_file.name, b"
...
" - ) - result = runner.invoke(djlint, [tmp_file.name]) - assert "H033" in result.output - - write_to_file( - tmp_file.name, - b"
...
", - ) - result = runner.invoke(djlint, [tmp_file.name]) - assert "H033" in result.output - - write_to_file( - tmp_file.name, b"
...
" - ) - result = runner.invoke(djlint, [tmp_file.name]) - assert "H033" in result.output - - write_to_file(tmp_file.name, b'
...
') - result = runner.invoke(djlint, [tmp_file.name]) - assert "H033" in result.output - - write_to_file( - tmp_file.name, b"
...
" - ) - result = runner.invoke(djlint, [tmp_file.name]) - assert "H033" in result.output - - write_to_file(tmp_file.name, b'
...
') - result = runner.invoke(djlint, [tmp_file.name]) - assert "H033" in result.output - - write_to_file(tmp_file.name, b'
...
') - result = runner.invoke(djlint, [tmp_file.name]) - assert "H033" in result.output - - def test_H035(runner: CliRunner, tmp_file: TextIO) -> None: write_to_file(tmp_file.name, b"") result = runner.invoke(djlint, [tmp_file.name])