Skip to content

Commit 71020be

Browse files
committed
tests: add test for an empty file
1 parent aafeb66 commit 71020be

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

tests/test_context.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ def test_context_linters_params(context):
6969
assert "enable" not in lparams
7070

7171

72+
def test_context_push_with_empty_file(context):
73+
ctx = context(code="")
74+
ctx.push(number="D100")
75+
assert ctx.errors
76+
77+
7278
def test_context_does_not_change_global_options(context, parse_args):
7379
"""Ensure a RunContext does not change the passed in options object."""
7480
options = parse_args(" --select=W123 --ignore=W234 --linters=pylint dummy.py")

tests/test_core.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,41 @@
44
def test_remove_duplicates():
55
from pylama.errors import Error, remove_duplicates
66

7-
errors = [Error(source='pycodestyle', text='E701'), Error(source='pylint', text='C0321')]
7+
errors = [
8+
Error(source="pycodestyle", text="E701"),
9+
Error(source="pylint", text="C0321"),
10+
]
811
errors = list(remove_duplicates(errors))
912
assert len(errors) == 1
1013

1114

1215
def test_checkpath(parse_options):
1316
from pylama.main import check_paths
1417

15-
path = op.abspath('dummy.py')
18+
path = op.abspath("dummy.py")
1619
options = parse_options([path])
1720
result = check_paths(None, options)
1821
assert result
19-
assert result[0].filename == 'dummy.py'
22+
assert result[0].filename == "dummy.py"
2023

2124

2225
def test_run_with_code(run, parse_options):
23-
options = parse_options(linters='pyflakes')
24-
errors = run('filename.py', code='unknown_call()', options=options)
26+
options = parse_options(linters="pyflakes")
27+
errors = run("filename.py", code="unknown_call()", options=options)
28+
assert errors
29+
30+
31+
def test_run_empty_code(run, parse_options):
32+
options = parse_options(linters="pyflakes")
33+
errors = run("filename.py", code="", options=options)
2534
assert errors
2635

2736

2837
def test_async(parse_options):
2938
from pylama.check_async import check_async
3039

3140
options = parse_options(config=False)
32-
errors = check_async(['dummy.py'], options=options, rootdir='.')
41+
errors = check_async(["dummy.py"], options=options, rootdir=".")
3342
assert errors
3443

3544

0 commit comments

Comments
 (0)