mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-09 00:30:59 +00:00
attemped to run tests on windows
This commit is contained in:
parent
22cf86ae82
commit
5fa1d326a7
2 changed files with 27 additions and 40 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
|
@ -11,5 +12,6 @@ def runner():
|
|||
|
||||
@pytest.fixture
|
||||
def tmp_file():
|
||||
with tempfile.NamedTemporaryFile() as tmp:
|
||||
yield tmp
|
||||
tmp = tempfile.NamedTemporaryFile(delete=False)
|
||||
yield tmp
|
||||
os.unlink(tmp.name)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ or::
|
|||
tox
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from src.djlint import main as djlint
|
||||
|
||||
|
|
@ -39,24 +40,24 @@ def test_bad_file(runner):
|
|||
def test_good_file(runner):
|
||||
result = runner.invoke(djlint, ["tests/bad.html"])
|
||||
assert result.exit_code == 0
|
||||
assert "tests/bad.html" in result.output
|
||||
assert str(Path("tests/bad.html")) in result.output
|
||||
|
||||
|
||||
def test_bad_path(runner):
|
||||
result = runner.invoke(djlint, ["tests/nowhere"])
|
||||
assert result.exit_code == 2
|
||||
assert "Path 'tests/nowhere' does not exist." in result.output
|
||||
assert "does not exist." in result.output
|
||||
|
||||
|
||||
def test_good_path_with_ext(runner):
|
||||
result = runner.invoke(djlint, ["tests/", "-e", "html"])
|
||||
assert result.exit_code == 0
|
||||
assert "tests/bad.html" in result.output
|
||||
assert str(Path("tests/bad.html")) in result.output
|
||||
|
||||
result = runner.invoke(djlint, ["tests/", "--extension", "html*"])
|
||||
assert result.exit_code == 0
|
||||
assert "tests/bad.html" in result.output
|
||||
assert "tests/bad.html.dj" in result.output
|
||||
assert str(Path("tests/bad.html")) in result.output
|
||||
assert str(Path("tests/bad.html.dj")) in result.output
|
||||
|
||||
|
||||
def test_good_path_with_bad_ext(runner):
|
||||
|
|
@ -66,15 +67,13 @@ def test_good_path_with_bad_ext(runner):
|
|||
|
||||
|
||||
def test_empty_file(runner, tmp_file):
|
||||
tmp_file.write(b"")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_E001(runner, tmp_file):
|
||||
tmp_file.write(b"{{test }}\n{% test%}")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"{{test }}\n{% test%}")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "E001 1:" in result.output
|
||||
|
|
@ -82,95 +81,84 @@ def test_E001(runner, tmp_file):
|
|||
|
||||
|
||||
def test_E002(runner, tmp_file):
|
||||
tmp_file.write(b"{% extends 'this' %}")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"{% extends 'this' %}")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "E002 1:" in result.output
|
||||
|
||||
|
||||
def test_W003(runner, tmp_file):
|
||||
tmp_file.write(b"{% endblock %}")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"{% endblock %}")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W003 1:" in result.output
|
||||
|
||||
|
||||
def test_W004(runner, tmp_file):
|
||||
tmp_file.write(b'<link src="/static/there">')
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b'<link src="/static/there">')
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W004 1:" in result.output
|
||||
|
||||
|
||||
def test_W005(runner, tmp_file):
|
||||
tmp_file.write(b"<!DOCTYPE html>\n<html>")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"<!DOCTYPE html>\n<html>")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W005 2:" in result.output
|
||||
|
||||
|
||||
def test_W006(runner, tmp_file):
|
||||
tmp_file.write(b"<img />")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"<img />")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W006 1:" in result.output
|
||||
|
||||
|
||||
def test_W007(runner, tmp_file):
|
||||
tmp_file.write(b'<html lang="en">')
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b'<html lang="en">')
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W007 1:" in result.output
|
||||
|
||||
|
||||
def test_W008(runner, tmp_file):
|
||||
tmp_file.write(b"<div class='test'>")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"<div class='test'>")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W008 1:" in result.output
|
||||
|
||||
|
||||
def test_W009(runner, tmp_file):
|
||||
tmp_file.write(b"<H1>")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"<H1>")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W009 1:" in result.output
|
||||
|
||||
|
||||
def test_W010(runner, tmp_file):
|
||||
tmp_file.write(b'<img HEIGHT="12">')
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b'<img HEIGHT="12">')
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W010 1:" in result.output
|
||||
|
||||
|
||||
def test_W011(runner, tmp_file):
|
||||
tmp_file.write(b"<div class=test></div>")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"<div class=test></div>")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W011 1:" in result.output
|
||||
|
||||
|
||||
def test_W012(runner, tmp_file):
|
||||
tmp_file.write(b'<div class = "stuff">')
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b'<div class = "stuff">')
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W012 1:" in result.output
|
||||
|
||||
|
||||
def test_W013(runner, tmp_file):
|
||||
tmp_file.write(
|
||||
open(tmp_file.name, mode="wb").write(
|
||||
b"this is a very long line of random long text that is very long and should not be so long, hopefully it thows an error somwhere"
|
||||
)
|
||||
tmp_file.seek(0)
|
||||
|
|
@ -180,24 +168,21 @@ def test_W013(runner, tmp_file):
|
|||
|
||||
|
||||
def test_W014(runner, tmp_file):
|
||||
tmp_file.write(b"</div>\n\n\n<p>")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"</div>\n\n\n<p>")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W014 1:" in result.output
|
||||
|
||||
|
||||
def test_W015(runner, tmp_file):
|
||||
tmp_file.write(b"</h1><p>")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"</h1><p>")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W015 1:" in result.output
|
||||
|
||||
|
||||
def test_W016(runner, tmp_file):
|
||||
tmp_file.write(b"<html>\nstuff\n</html>")
|
||||
tmp_file.seek(0)
|
||||
open(tmp_file.name, mode="wb").write(b"<html>\nstuff\n</html>")
|
||||
result = runner.invoke(djlint, [tmp_file.name])
|
||||
assert result.exit_code == 0
|
||||
assert "W016 1:" in result.output
|
||||
|
|
|
|||
Loading…
Reference in a new issue