Skip to content

Commit c403271

Browse files
committed
Add test for handling Python files that are not in UTF8
1 parent 0941b8f commit c403271

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: shift_jis -*-
2+
3+
from .imported import ƒÎ

tests/functional/test_encoding_handling.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,23 @@ def test_build_graph_of_non_ascii_source():
1919
"line_contents": "from .imported import π",
2020
},
2121
] == result
22+
23+
24+
def test_build_graph_of_non_utf8_source():
25+
"""
26+
Tests we can cope with non UTF-8 Python source files.
27+
"""
28+
graph = grimp.build_graph("encodingpackage", cache_dir=None)
29+
30+
result = graph.get_import_details(
31+
importer="encodingpackage.shift_jis_importer", imported="encodingpackage.imported"
32+
)
33+
34+
assert [
35+
{
36+
"importer": "encodingpackage.shift_jis_importer",
37+
"imported": "encodingpackage.imported",
38+
"line_number": 3,
39+
"line_contents": "from .imported import π",
40+
},
41+
] == result

0 commit comments

Comments
 (0)