aboutsummaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2021-02-12 12:04:46 -0800
committerGitHub <noreply@github.com>2021-02-12 12:04:46 -0800
commitfd053fdd39fbdf114b4218ea4309666bafa95788 (patch)
tree360827543b553179e7d8526506106076071874d8 /Lib
parentbpo-43204: Fix LibTomCrypt URL in md5module.c and sha*module.c comments (GH-2... (diff)
downloadcpython-fd053fdd39fbdf114b4218ea4309666bafa95788.tar.gz
cpython-fd053fdd39fbdf114b4218ea4309666bafa95788.tar.bz2
cpython-fd053fdd39fbdf114b4218ea4309666bafa95788.zip
bpo-43172: readline now passes its tests when built against libedit (GH-24499)
bpo-43172: readline now passes its tests when built against libedit. Existing irreconcilable API differences remain in readline.get_begidx and readline.get_endidx behavior based on libreadline vs libedit use. A note about that has been documented.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_readline.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/test/test_readline.py b/Lib/test/test_readline.py
index de573bef9f9..f3e404da6f0 100644
--- a/Lib/test/test_readline.py
+++ b/Lib/test/test_readline.py
@@ -102,8 +102,15 @@ class TestHistoryManipulation (unittest.TestCase):
# test 'no such file' behaviour
os.unlink(hfilename)
- with self.assertRaises(FileNotFoundError):
+ try:
readline.append_history_file(1, hfilename)
+ except FileNotFoundError:
+ pass # Some implementations return this error (libreadline).
+ else:
+ os.unlink(hfilename) # Some create it anyways (libedit).
+ # If the file wasn't created, unlink will fail.
+ # We're just testing that one of the two expected behaviors happens
+ # instead of an incorrect error.
# write_history_file can create the target
readline.write_history_file(hfilename)
@@ -228,7 +235,17 @@ print("history", ascii(readline.get_history_item(1)))
output = run_pty(script, input)
self.assertIn(b"text 't\\xeb'\r\n", output)
self.assertIn(b"line '[\\xefnserted]|t\\xeb[after]'\r\n", output)
- self.assertIn(b"indexes 11 13\r\n", output)
+ if sys.platform == "darwin" or not is_editline:
+ self.assertIn(b"indexes 11 13\r\n", output)
+ # Non-macOS libedit does not handle non-ASCII bytes
+ # the same way and generates character indices
+ # rather than byte indices via get_begidx() and
+ # get_endidx(). Ex: libedit2 3.1-20191231-2 on Debian
+ # winds up with "indexes 10 12". Stemming from the
+ # start and end values calls back into readline.c's
+ # rl_attempted_completion_function = flex_complete with:
+ # (11, 13) instead of libreadline's (12, 15).
+
if not is_editline and hasattr(readline, "set_pre_input_hook"):
self.assertIn(b"substitution 't\\xeb'\r\n", output)
self.assertIn(b"matches ['t\\xebnt', 't\\xebxt']\r\n", output)