-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(formatter): added
max-blank-lines
flag to consolidate blank lines
closes #675
- Loading branch information
1 parent
19425f9
commit 4a7897f
Showing
9 changed files
with
115 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Test for max blank lines. | ||
poetry run pytest tests/test_config/test_max_blank_lines.py | ||
""" | ||
import pytest | ||
|
||
from src.djlint.reformat import formatter | ||
from tests.conftest import config_builder, printer | ||
|
||
test_data = [ | ||
pytest.param( | ||
("<img>\n\n\n\n\n\n\n\n\n\n<meta>"), | ||
("<img>\n" "<meta>\n"), | ||
({}), | ||
id="default", | ||
), | ||
pytest.param( | ||
("<img>\n\n\n\n\n\n\n\n\n\n<meta>"), | ||
("<img>\n\n\n\n\n\n" "<meta>\n"), | ||
({"max_blank_lines": 5}), | ||
id="5", | ||
), | ||
pytest.param( | ||
("<img>\n\n\n\n\n\n\n\n\n\n<meta>"), | ||
("<img>\n\n" "<meta>\n"), | ||
({"max_blank_lines": 1}), | ||
id="1", | ||
), | ||
pytest.param( | ||
("<img>\n\n\n\n\n\n\n\n\n\n<meta>"), | ||
("<img>\n" "<meta>\n"), | ||
({"max_blank_lines": -1}), | ||
id="-1", | ||
), | ||
pytest.param( | ||
("<img>\n\n\n\n\n\n\n\n\n\n<meta>"), | ||
("<img>\n\n\n\n\n\n\n\n\n\n" "<meta>\n"), | ||
({"max_blank_lines": 30}), | ||
id="30", | ||
), | ||
pytest.param( | ||
("<img>\n\n<div>\n\n<p>\n\n</p>\n\n</div>\n\n<meta>"), | ||
("<img>\n" "\n" "<div>\n" "\n" " <p></p>\n" "\n" "</div>\n" "\n" "<meta>\n"), | ||
({"max_blank_lines": 30}), | ||
id="div", | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize(("source", "expected", "args"), test_data) | ||
def test_base(source, expected, args): | ||
output = formatter(config_builder(args), source) | ||
|
||
printer(expected, source, output) | ||
assert expected == output |