Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-133390: Support basic completion for sqlite3 command-line interface#133393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes from1 commit
1b96be3
5e50871
c1941cb
47daca5
c54c2f6
8fff491
a766805
da55014
ca587e0
311b4f3
70f46e9
9d03730
bfcff38
805d997
276b4a7
09eeac8
fc57d71
c508069
231b9e7
121b069
90a86cf
5170733
b40982a
226ea9f
4eebbd9
3f9b2c1
0410fa2
bd0b9ce
35a17e7
3dd16b3
f3ea951
a493ad3
34cfc78
477b48b
68bb4f3
4c3b122
4f1221e
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -207,6 +207,8 @@ def test_color(self): | ||
@requires_subprocess() | ||
picnixz marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
class CompletionTest(unittest.TestCase): | ||
PS1 = "sqlite> " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is no longer freely customizable by users via sys.ps1 ? | ||
@classmethod | ||
def setUpClass(cls): | ||
readline = import_module("readline") | ||
@@ -239,24 +241,38 @@ def test_nothing_to_complete(self): | ||
readline.parse_and_bind("set colored-completion-prefix off") | ||
from sqlite3.__main__ import main; main() | ||
""") | ||
input = b"xyzzy\t\t\b\b\b\b\b.quit\n" | ||
output = run_pty(script, input, env={"NO_COLOR": "1"}) | ||
output_lines = output.decode().splitlines() | ||
line_num = next(i for i, line in enumerate(output_lines, 1) | ||
if line.startswith(f"{self.PS1}xyzzy")) | ||
picnixz marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
# completions occupy lines, assert no extra lines when there is nothing | ||
# to complete | ||
self.assertEqual(line_num, len(output_lines)) | ||
def test_completion_order(self): | ||
script = textwrap.dedent(""" | ||
import readline | ||
readline.parse_and_bind("set colored-completion-prefix off") | ||
# hide control sequences surrounding each candidate | ||
readline.parse_and_bind("set colored-stats off") | ||
# hide "Display all xxx possibilities? (y or n)" | ||
readline.parse_and_bind("set completion-query-items 0") | ||
# hide "--More--" | ||
readline.parse_and_bind("set page-completions off") | ||
# show candidates one per line | ||
readline.parse_and_bind("set completion-display-width 0") | ||
from sqlite3.__main__ import main; main() | ||
""") | ||
input = b"\t\t.quit\n" | ||
output = run_pty(script, input, env={"NO_COLOR": "1"}) | ||
output_lines = output.decode().splitlines() | ||
candidates = [] | ||
for line in output_lines[-2::-1]: | ||
picnixz marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if line.startswith(self.PS1): | ||
break | ||
candidates.append(line.strip()) | ||
self.assertEqual(sorted(candidates, reverse=True), candidates) | ||
picnixz marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if __name__ == "__main__": | ||
unittest.main() |
Uh oh!
There was an error while loading.Please reload this page.