summaryrefslogtreecommitdiff
path: root/tests/test_utils.py
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2014-05-26 12:08:52 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2014-05-26 12:08:52 +0200
commit537d6d57851f25a2eb566b577384904bc4a05362 (patch)
tree2270ef8b1a323d62cff1729f51bb646b22511e6e /tests/test_utils.py
parentaef16506b5da26684103db2e47346dbf49a7e7a1 (diff)
downloadclick-537d6d57851f25a2eb566b577384904bc4a05362.tar.gz
Unbroke colorama integrated echo for unicode.
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 438de00..c6bca72 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,3 +1,4 @@
+import sys
import click
@@ -11,6 +12,24 @@ def test_echo(runner):
bytes = out.getvalue()
assert bytes == b'\xe2\x98\x83\nDD\n42ax'
+ # If we are on python 2 we expect that writing bytes into a string io
+ # does not do anything crazy. On Python 3
+ if sys.version_info[0] == 2:
+ import StringIO
+ sys.stdout = x = StringIO.StringIO()
+ try:
+ click.echo('\xf6')
+ finally:
+ sys.stdout = sys.__stdout__
+ assert x.getvalue() == '\xf6\n'
+
+ # And in any case, if wrapped, we expect bytes to survive.
+ @click.command()
+ def cli():
+ click.echo(b'\xf6')
+ result = runner.invoke(cli, [])
+ assert result.output_bytes == b'\xf6\n'
+
def test_filename_formatting():
assert click.format_filename(b'foo.txt') == 'foo.txt'