Skip to content

Commit 65cc354

Browse files
committed
Add tests with unicode data. Fix few issues.
1 parent 9df15e3 commit 65cc354

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

src/hunter.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from __future__ import absolute_import
2-
from __future__ import unicode_literals
32

43
import ast
54
import atexit
@@ -231,7 +230,6 @@ def yield_lines(filename, start, collector,
231230
amount = len(dedent)
232231
elif not line.startswith(dedent):
233232
break
234-
# print(start, repr(line))
235233
collector(line)
236234
yield line[amount:]
237235

tests/sample2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- encoding: utf-8 -*-
2-
if __name__ == "__main__":
2+
if __name__ == "__main__": # ăăăă
33
import functools
44

55
def deco(opt):
@@ -17,13 +17,13 @@ def foo(*args):
1717
return args
1818

1919
foo(
20-
'a',
20+
'aăă',
2121
'b'
2222
)
2323
try:
2424
None(
2525
'a',
2626
'b'
27-
) # doh!
27+
) # dăh!
2828
except:
2929
pass

tests/test_hunter.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import os
44
import subprocess
55
from fnmatch import fnmatchcase
6-
from io import StringIO
6+
try:
7+
from StringIO import StringIO
8+
except ImportError:
9+
from io import StringIO
710
try:
811
from itertools import izip_longest
912
except ImportError:
@@ -50,8 +53,8 @@ def test_pth_sample2():
5053
stderr=subprocess.STDOUT,
5154
)
5255
for line, expected in izip_longest(output.decode('utf8').splitlines(), [
53-
'* tests/sample2.py:* call if __name__ == "__main__":',
54-
'* tests/sample2.py:* line if __name__ == "__main__":',
56+
'* tests/sample2.py:* call if __name__ == "__main__": #*',
57+
'* tests/sample2.py:* line if __name__ == "__main__": #*',
5558
'* tests/sample2.py:* line import functools',
5659
'* tests/sample2.py:* line def deco(opt):',
5760
'* tests/sample2.py:* line @deco(1)',
@@ -88,7 +91,7 @@ def test_pth_sample2():
8891
'* tests/sample2.py:* return return wrapper',
8992
'* * ... return value: <function foo *',
9093
'* tests/sample2.py:* line foo(',
91-
"* tests/sample2.py:* line 'a',",
94+
"* tests/sample2.py:* line 'a*',",
9295
"* tests/sample2.py:* line 'b'",
9396
'* tests/sample2.py:* call @functools.wraps(func)',
9497
'* * | def wrapper(*args):',
@@ -105,13 +108,13 @@ def test_pth_sample2():
105108
'* * | def foo(*args):',
106109
'* tests/sample2.py:* line return args',
107110
'* tests/sample2.py:* return return args',
108-
"* * ... return value: ('a', 'b')",
111+
"* * ... return value: ('a*', 'b')",
109112
"* tests/sample2.py:* return return func(*args)",
110-
"* * ... return value: ('a', 'b')",
113+
"* * ... return value: ('a*', 'b')",
111114
"* tests/sample2.py:* return return func(*args)",
112-
"* * ... return value: ('a', 'b')",
115+
"* * ... return value: ('a*', 'b')",
113116
"* tests/sample2.py:* return return func(*args)",
114-
"* * ... return value: ('a', 'b')",
117+
"* * ... return value: ('a*', 'b')",
115118
"* tests/sample2.py:* line try:",
116119
"* tests/sample2.py:* line None(",
117120
"* tests/sample2.py:* line 'a',",

0 commit comments

Comments
 (0)