File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def main(argv=None): # type: (Optional[Sequence[str]]) -> int
1919 with open (filename ) as f :
2020 toml .load (f )
2121 except toml .TomlDecodeError as exc :
22- print (exc )
22+ print ('{}: {}' . format ( filename , exc ) )
2323 retval = 1
2424 return retval
2525
Original file line number Diff line number Diff line change 1+ from __future__ import absolute_import
2+ from __future__ import unicode_literals
3+
4+ from pre_commit_hooks .check_toml import main
5+
6+
7+ def test_toml_good (tmpdir ):
8+ filename = tmpdir .join ('f' )
9+ filename .write ("""
10+ key = # INVALID
11+
12+ = "no key name" # INVALID
13+ """ )
14+ ret = main ((filename .strpath ,))
15+ assert ret == 1
16+
17+
18+ def test_toml_bad (tmpdir ):
19+ filename = tmpdir .join ('f' )
20+ filename .write (
21+ """
22+ # This is a TOML document.
23+
24+ title = "TOML Example"
25+
26+ [owner]
27+ name = "John"
28+ dob = 1979-05-27T07:32:00-08:00 # First class dates
29+ """ ,
30+ )
31+ ret = main ((filename .strpath ,))
32+ assert ret == 0
You can’t perform that action at this time.
0 commit comments