summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2023-11-28 06:23:23 (GMT)
committerGitHub <noreply@github.com>2023-11-28 06:23:23 (GMT)
commit2df26d83486b8f9ac6b7df2a9a4669508aa61983 (patch)
tree1dbbc29f644f44dd7881427bfbac5294ac2da57c /Lib
parentac4b44266d61651aea5928ce7d3fae4de226f83d (diff)
downloadcpython-2df26d83486b8f9ac6b7df2a9a4669508aa61983.zip
cpython-2df26d83486b8f9ac6b7df2a9a4669508aa61983.tar.gz
cpython-2df26d83486b8f9ac6b7df2a9a4669508aa61983.tar.bz2
gh-112105: Make completer delims work on libedit (gh-112106)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_readline.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_readline.py b/Lib/test/test_readline.py
index 835280f..6c2726d 100644
--- a/Lib/test/test_readline.py
+++ b/Lib/test/test_readline.py
@@ -5,6 +5,7 @@ import locale
import os
import sys
import tempfile
+import textwrap
import unittest
from test.support import verbose
from test.support.import_helper import import_module
@@ -163,6 +164,25 @@ print("History length:", readline.get_current_history_length())
# end, so don't expect it in the output.
self.assertIn(b"History length: 0", output)
+ def test_set_complete_delims(self):
+ script = textwrap.dedent("""
+ import readline
+ def complete(text, state):
+ if state == 0 and text == "$":
+ return "$complete"
+ return None
+ if "libedit" in getattr(readline, "__doc__", ""):
+ readline.parse_and_bind(r'bind "\\t" rl_complete')
+ else:
+ readline.parse_and_bind(r'"\\t": complete')
+ readline.set_completer_delims(" \\t\\n")
+ readline.set_completer(complete)
+ print(input())
+ """)
+
+ output = run_pty(script, input=b"$\t\n")
+ self.assertIn(b"$complete", output)
+
def test_nonascii(self):
loc = locale.setlocale(locale.LC_CTYPE, None)
if loc in ('C', 'POSIX'):