MCPcopy Index your code
hub / github.com/python/cpython / test_complete_no_input

Method test_complete_no_input

Lib/test/test_sqlite3/test_cli.py:400–437  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

398 self.assertEqual(line_num, len(lines))
399
400 def test_complete_no_input(self):
401 script = textwrap.dedent("""
402 import readline
403 from sqlite3.__main__ import main
404
405 # Configure readline to ...:
406 # - hide control sequences surrounding each candidate
407 # - hide "Display all xxx possibilities? (y or n)"
408 # - hide "--More--"
409 # - show candidates one per line
410 readline.parse_and_bind("set colored-completion-prefix off")
411 readline.parse_and_bind("set colored-stats off")
412 readline.parse_and_bind("set completion-query-items 0")
413 readline.parse_and_bind("set page-completions off")
414 readline.parse_and_bind("set completion-display-width 0")
415 readline.parse_and_bind("set show-all-if-ambiguous off")
416 readline.parse_and_bind("set show-all-if-unmodified off")
417
418 main()
419 """)
420 input_ = b"\t\t.quit\n"
421 output = run_pty(script, input_, env={**os.environ, "NO_COLOR": "1"})
422 try:
423 lines = output.decode().splitlines()
424 indices = [
425 i for i, line in enumerate(lines)
426 if line.startswith(self.PS1)
427 ]
428 self.assertEqual(len(indices), 2)
429 start, end = indices
430 candidates = [l.strip() for l in lines[start+1:end]]
431 self.assertEqual(candidates, sorted(candidates))
432 except:
433 if verbose:
434 print(' PTY output: '.center(30, '-'))
435 print(output.decode(errors='replace'))
436 print(' end PTY output '.center(30, '-'))
437 raise
438
439
440

Callers

nothing calls this directly

Calls 9

run_ptyFunction · 0.90
enumerateFunction · 0.85
dedentMethod · 0.45
splitlinesMethod · 0.45
decodeMethod · 0.45
startswithMethod · 0.45
assertEqualMethod · 0.45
stripMethod · 0.45
centerMethod · 0.45

Tested by

no test coverage detected