diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-01-31 23:37:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-01 09:37:29 +0200 |
commit | 304f9d2622fa4fd0833d60d31ddf7321a6a8141b (patch) | |
tree | b7d95bed058b0064612e7f450a5bc9fe9686c5b3 | |
parent | bpo-42688: Fix ffi alloc/free when using external libffi on macos (GH-23868) ... (diff) | |
download | cpython-304f9d2622fa4fd0833d60d31ddf7321a6a8141b.tar.gz cpython-304f9d2622fa4fd0833d60d31ddf7321a6a8141b.tar.bz2 cpython-304f9d2622fa4fd0833d60d31ddf7321a6a8141b.zip |
bpo-43016: Fix test_curses on platform without cursesw (GH-24405) (GH-24407)
(cherry picked from commit a1e9a1e120a11c563e166c15721169184c802f8b)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
-rw-r--r-- | Lib/test/test_curses.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index f5287e0143f..c1ad23b456e 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -239,13 +239,21 @@ class TestCurses(unittest.TestCase): def test_output_character(self): stdscr = self.stdscr + encoding = stdscr.encoding # addch() stdscr.refresh() stdscr.move(0, 0) stdscr.addch('A') stdscr.addch(b'A') stdscr.addch(65) - stdscr.addch('\u20ac') + c = '\u20ac' + try: + stdscr.addch(c) + except UnicodeEncodeError: + self.assertRaises(UnicodeEncodeError, c.encode, encoding) + except OverflowError: + encoded = c.encode(encoding) + self.assertNotEqual(len(encoded), 1, repr(encoded)) stdscr.addch('A', curses.A_BOLD) stdscr.addch(1, 2, 'A') stdscr.addch(2, 3, 'A', curses.A_BOLD) @@ -257,19 +265,25 @@ class TestCurses(unittest.TestCase): stdscr.echochar('A') stdscr.echochar(b'A') stdscr.echochar(65) - self.assertRaises(OverflowError, stdscr.echochar, '\u20ac') + with self.assertRaises((UnicodeEncodeError, OverflowError)): + stdscr.echochar('\u20ac') stdscr.echochar('A', curses.A_BOLD) self.assertIs(stdscr.is_wintouched(), False) def test_output_string(self): stdscr = self.stdscr + encoding = stdscr.encoding # addstr()/insstr() for func in [stdscr.addstr, stdscr.insstr]: with self.subTest(func.__qualname__): stdscr.move(0, 0) func('abcd') func(b'abcd') - func('àßçđ') + s = 'àßçđ' + try: + func(s) + except UnicodeEncodeError: + self.assertRaises(UnicodeEncodeError, s.encode, encoding) func('abcd', curses.A_BOLD) func(1, 2, 'abcd') func(2, 3, 'abcd', curses.A_BOLD) @@ -280,7 +294,11 @@ class TestCurses(unittest.TestCase): stdscr.move(0, 0) func('1234', 3) func(b'1234', 3) - func('\u0661\u0662\u0663\u0664', 3) + s = '\u0661\u0662\u0663\u0664' + try: + func(s, 3) + except UnicodeEncodeError: + self.assertRaises(UnicodeEncodeError, s.encode, encoding) func('1234', 5) func('1234', 3, curses.A_BOLD) func(1, 2, '1234', 3) @@ -470,7 +488,7 @@ class TestCurses(unittest.TestCase): win = curses.newwin(5, 15, 5, 2) win.addstr(0, 0, 'Lorem ipsum') - self.assertEqual(win.getbkgd(), 0) + self.assertIn(win.getbkgd(), (0, 32)) # bkgdset() win.bkgdset('_') |