File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
13
13
retval = 0
14
14
for filename in args .filenames :
15
15
try :
16
- with open (filename ) as f :
17
- toml .load (f )
16
+ toml .load (filename )
18
17
except toml .TomlDecodeError as exc :
19
18
print (f'{ filename } : { exc } ' )
20
19
retval = 1
Original file line number Diff line number Diff line change 1
1
from pre_commit_hooks .check_toml import main
2
2
3
3
4
- def test_toml_good (tmpdir ):
4
+ def test_toml_bad (tmpdir ):
5
5
filename = tmpdir .join ('f' )
6
6
filename .write ("""
7
7
key = # INVALID
@@ -12,7 +12,7 @@ def test_toml_good(tmpdir):
12
12
assert ret == 1
13
13
14
14
15
- def test_toml_bad (tmpdir ):
15
+ def test_toml_good (tmpdir ):
16
16
filename = tmpdir .join ('f' )
17
17
filename .write (
18
18
"""
@@ -27,3 +27,10 @@ def test_toml_bad(tmpdir):
27
27
)
28
28
ret = main ((filename .strpath ,))
29
29
assert ret == 0
30
+
31
+
32
+ def test_toml_good_unicode (tmpdir ):
33
+ filename = tmpdir .join ('f' )
34
+ filename .write_binary ('letter = "\N{SNOWMAN} "\n ' .encode ())
35
+ ret = main ((filename .strpath ,))
36
+ assert ret == 0
You can’t perform that action at this time.
0 commit comments