summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_curses.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-11-25 21:10:02 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-11-25 21:10:02 (GMT)
commit0fdfceb782424dcddca848357736f24ef40c91be (patch)
tree4accbe6422e2e28b0dc80d5b105c5da8f285bfcd /Lib/test/test_curses.py
parentc24847658fb1e676391d3db1096219581cd2782c (diff)
downloadcpython-0fdfceb782424dcddca848357736f24ef40c91be.zip
cpython-0fdfceb782424dcddca848357736f24ef40c91be.tar.gz
cpython-0fdfceb782424dcddca848357736f24ef40c91be.tar.bz2
Issue #12567: The curses module uses Unicode functions for Unicode arguments
when it is linked to the ncurses library. It encodes also Unicode strings to the locale encoding instead of UTF-8.
Diffstat (limited to 'Lib/test/test_curses.py')
-rw-r--r--Lib/test/test_curses.py43
1 files changed, 31 insertions, 12 deletions
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index 72be3e7..b416403 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -267,24 +267,42 @@ def test_issue6243(stdscr):
def test_unget_wch(stdscr):
if not hasattr(curses, 'unget_wch'):
return
- ch = 'a'
- curses.unget_wch(ch)
- read = stdscr.get_wch()
- read = chr(read)
- if read != ch:
- raise AssertionError("%r != %r" % (read, ch))
-
- ch = ord('a')
- curses.unget_wch(ch)
- read = stdscr.get_wch()
- if read != ch:
- raise AssertionError("%r != %r" % (read, ch))
+ for ch in ('a', '\xe9', '\u20ac', '\U0010FFFF'):
+ curses.unget_wch(ch)
+ read = stdscr.get_wch()
+ read = chr(read)
+ if read != ch:
+ raise AssertionError("%r != %r" % (read, ch))
+
+ code = ord(ch)
+ curses.unget_wch(code)
+ read = stdscr.get_wch()
+ if read != code:
+ raise AssertionError("%r != %r" % (read, code))
def test_issue10570():
b = curses.tparm(curses.tigetstr("cup"), 5, 3)
assert type(b) is bytes
curses.putp(b)
+def test_encoding(stdscr):
+ import codecs
+ encoding = stdscr.encoding
+ codecs.lookup(encoding)
+ try:
+ stdscr.encoding = 10
+ except TypeError:
+ pass
+ else:
+ raise AssertionError("TypeError not raised")
+ stdscr.encoding = encoding
+ try:
+ del stdscr.encoding
+ except TypeError:
+ pass
+ else:
+ raise AssertionError("TypeError not raised")
+
def main(stdscr):
curses.savetty()
try:
@@ -295,6 +313,7 @@ def main(stdscr):
test_issue6243(stdscr)
test_unget_wch(stdscr)
test_issue10570()
+ test_encoding(stdscr)
finally:
curses.resetty()