summaryrefslogtreecommitdiff
path: root/tests/test_ansi.py
diff options
context:
space:
mode:
authorDavid O'Shea <doshea@doshea-centos-x86-64.adl.quantum.com>2014-08-01 17:10:58 +0930
committerDavid O'Shea <doshea@doshea-centos-x86-64.adl.quantum.com>2014-08-01 17:27:13 +0930
commita4b8165da2a7f356e3a12b091727e33e6fcc0d2c (patch)
treeb023c3562763c8d6ab94b339509acd1e08d46d61 /tests/test_ansi.py
parent05711ea5004a9d9bf8164fc75e90a6a7c79b5c18 (diff)
downloadpexpect-a4b8165da2a7f356e3a12b091727e33e6fcc0d2c.tar.gz
Don't define __bytes__(), and don't define __unicode__() on Python 3.
The previous attempt to add unicode support tried to make Python 2 and 3 behave in the same way apart from __str__(). This commit makes the modules, and the tests, provide only __str__() on Python 3 and both __str__() and __unicode__() on Python 2.
Diffstat (limited to 'tests/test_ansi.py')
-rwxr-xr-xtests/test_ansi.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/test_ansi.py b/tests/test_ansi.py
index 4806bff..33d21bc 100755
--- a/tests/test_ansi.py
+++ b/tests/test_ansi.py
@@ -24,8 +24,6 @@ from . import PexpectTestCase
import sys
PY3 = (sys.version_info[0] >= 3)
-if PY3:
- unicode = str
write_target = 'I\'ve got a ferret sticking up my nose. \n' +\
'(He\'s got a ferret sticking up his nose.) \n' +\
@@ -166,8 +164,11 @@ class ansiTestCase (PexpectTestCase.PexpectTestCase):
s.write(b'\xe2\x8c\x9b')
s.write(b'\xe2\x8c')
s.write(b'\xa8')
- assert unicode(s) == u'\u231b\u2328 \n '
- assert bytes(s) == b'\xe2\x8c\x9b\xe2\x8c\xa8 \n '
+ if PY3:
+ assert str(s) == u'\u231b\u2328 \n '
+ else:
+ assert unicode(s) == u'\u231b\u2328 \n '
+ assert str(s) == b'\xe2\x8c\x9b\xe2\x8c\xa8 \n '
assert s.dump() == u'\u231b\u2328 '
assert s.pretty() == u'+----------+\n|\u231b\u2328 |\n| |\n+----------+\n'
assert s.get_abs(1, 1) == u'\u231b'
@@ -177,8 +178,11 @@ class ansiTestCase (PexpectTestCase.PexpectTestCase):
"""Test passing in of a unicode string."""
s = ANSI.ANSI(2, 10, encoding="utf-8")
s.write(u'\u231b\u2328')
- assert unicode(s) == u'\u231b\u2328 \n '
- assert bytes(s) == b'\xe2\x8c\x9b\xe2\x8c\xa8 \n '
+ if PY3:
+ assert str(s) == u'\u231b\u2328 \n '
+ else:
+ assert unicode(s) == u'\u231b\u2328 \n '
+ assert str(s) == b'\xe2\x8c\x9b\xe2\x8c\xa8 \n '
assert s.dump() == u'\u231b\u2328 '
assert s.pretty() == u'+----------+\n|\u231b\u2328 |\n| |\n+----------+\n'
assert s.get_abs(1, 1) == u'\u231b'
@@ -191,8 +195,11 @@ class ansiTestCase (PexpectTestCase.PexpectTestCase):
s.write(b'\xff') # a non-ASCII character
# In unicode, the non-ASCII character is replaced with
# REPLACEMENT CHARACTER.
- assert unicode(s) == u'\ufffd \n '
- assert bytes(s) == b'? \n '
+ if PY3:
+ assert str(s) == u'\ufffd \n '
+ else:
+ assert unicode(s) == u'\ufffd \n '
+ assert str(s) == b'? \n '
assert s.dump() == u'\ufffd '
assert s.pretty() == u'+----------+\n|\ufffd |\n| |\n+----------+\n'
assert s.get_abs(1, 1) == u'\ufffd'