Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pre_commit_hooks/check_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
retval = 0
for filename in args.filenames:
try:
with open(filename) as f:
toml.load(f)
toml.load(filename)
except toml.TomlDecodeError as exc:
print(f'{filename}: {exc}')
retval = 1
Expand Down
11 changes: 9 additions & 2 deletions tests/check_toml_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pre_commit_hooks.check_toml import main


def test_toml_good(tmpdir):
def test_toml_bad(tmpdir):
filename = tmpdir.join('f')
filename.write("""
key = # INVALID
Expand All @@ -12,7 +12,7 @@ def test_toml_good(tmpdir):
assert ret == 1


def test_toml_bad(tmpdir):
def test_toml_good(tmpdir):
filename = tmpdir.join('f')
filename.write(
"""
Expand All @@ -27,3 +27,10 @@ def test_toml_bad(tmpdir):
)
ret = main((filename.strpath,))
assert ret == 0


def test_toml_good_unicode(tmpdir):
filename = tmpdir.join('f')
filename.write_binary('letter = "\N{SNOWMAN}"\n'.encode())
ret = main((filename.strpath,))
assert ret == 0