|
33 | 33 | import subprocess |
34 | 34 | import inspect |
35 | 35 |
|
36 | | -# allow unicode for stdin / stdout, it's a mess |
37 | | -try: |
38 | | - # python 3 |
39 | | - sys.stderr = io.TextIOWrapper( |
40 | | - sys.stderr.detach(), encoding='UTF-8', line_buffering=True) |
41 | | - |
42 | | -except AttributeError: # pragma: no cover |
43 | | - # python 2 |
44 | | - import codecs |
45 | | - utf8_writer = codecs.getwriter('UTF-8') |
46 | | - sys.stderr = utf8_writer(sys.stderr) |
| 36 | +sys.stderr = io.TextIOWrapper( |
| 37 | + sys.stderr.detach(), encoding='UTF-8', line_buffering=True) |
47 | 38 |
|
48 | 39 | import fprettify |
49 | 40 | from fprettify.fparse_utils import FprettifyParseException, FprettifyInternalException |
@@ -76,9 +67,7 @@ def eprint(*args, **kwargs): |
76 | 67 | Print to stderr - to print output compatible with default unittest output. |
77 | 68 | """ |
78 | 69 |
|
79 | | - print(*args, file=sys.stderr, **kwargs) |
80 | | - sys.stderr.flush() # python 2 print does not have flush argument |
81 | | - |
| 70 | + print(*args, file=sys.stderr, flush=True, **kwargs) |
82 | 71 |
|
83 | 72 | class FPrettifyTestCase(unittest.TestCase): |
84 | 73 | """ |
@@ -943,12 +932,7 @@ def test_result(path, info): |
943 | 932 |
|
944 | 933 | # not sure why this even works, using "test something" (with a space) as function name... |
945 | 934 | # however it gives optimal test output |
946 | | - try: |
947 | | - testmethod.__name__ = ("test " + joinpath(fpath, ffile)) |
948 | | - except TypeError: # pragma: no cover |
949 | | - # need to encode in python 2 since we are using unicode strings |
950 | | - testmethod.__name__ = ( |
951 | | - "test " + joinpath(fpath, ffile)).encode('utf-8') |
| 935 | + testmethod.__name__ = ("test " + joinpath(fpath, ffile)) |
952 | 936 |
|
953 | 937 | setattr(testcase, testmethod.__name__, testmethod) |
954 | 938 |
|
|
0 commit comments