diff options
author | Nikolay Orlyuk <virkony@gmail.com> | 2019-01-17 23:30:33 +0100 |
---|---|---|
committer | Nikolay Orlyuk <virkony@gmail.com> | 2019-01-17 23:30:33 +0100 |
commit | d5cad2f95623372e7cad9ebb581f42b5b9c1906e (patch) | |
tree | 8b56e1dac05f9d49db14f81e5cfd1ccd2ce82280 /tests/test_cmdline.py | |
parent | 3b7d4a5000e2f80f98ad31882dfbde53aed4d466 (diff) | |
download | pygments-git-d5cad2f95623372e7cad9ebb581f42b5b9c1906e.tar.gz |
Use unicode literals in docstrings as well
Resolves #1492
Diffstat (limited to 'tests/test_cmdline.py')
-rw-r--r-- | tests/test_cmdline.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 1500c875..a55e30ec 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -28,6 +28,13 @@ def func(args): ''' +def _decode_output(text): + try: + return text.decode('utf-8') + except UnicodeEncodeError: # implicit encode on Python 2 with data loss + return text + + def run_cmdline(*args, **kwds): saved_stdin = sys.stdin saved_stdout = sys.stdout @@ -53,9 +60,9 @@ def run_cmdline(*args, **kwds): sys.stderr = saved_stderr new_stdout.flush() new_stderr.flush() - out, err = stdout_buffer.getvalue().decode('utf-8'), \ - stderr_buffer.getvalue().decode('utf-8') - return (ret, out, err) + out, err = stdout_buffer.getvalue(), \ + stderr_buffer.getvalue() + return (ret, _decode_output(out), _decode_output(err)) class CmdLineTest(unittest.TestCase): |