Skip to content

test_cmd fails if build with editline not readline #150922

Closed

Description

@rossburton

Bug report

Bug description:

If I build cpython 3.14.5 with libedit 20260512-3.1 on Linux instead of GNU readline, test_cmd fails:

FAIL: test_bang_completion_without_do_shell (test.test_cmd.CmdTestReadline.test_bang_completion_without_do_shell) (input=b'! h\t\n')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.14/test/test_cmd.py", line 319, in test_bang_completion_without_do_shell
    self.assertIn(b'hello', output)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
AssertionError: b'hello' not found in bytearray(b'! h\t\r\n(Cmd) ! h\x07\r\x1b[9Cello\r\ntab completion success\r\n')

======================================================================
FAIL: test_bang_completion_without_do_shell (test.test_cmd.CmdTestReadline.test_bang_completion_without_do_shell) (input=b'!h\t\n')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.14/test/test_cmd.py", line 319, in test_bang_completion_without_do_shell
    self.assertIn(b'hello', output)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
AssertionError: b'hello' not found in bytearray(b'!h\t\r\n(Cmd) !h\x07\r\x1b[8Cello\r\ntab completion success\r\n')

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

Activity

  1. zainnadeem786 commented on Jun 28, 2026

    @zainnadeem786
    Contributor

    Hi all,

    I investigated this on the latest main using a pydebug build on WSL Ubuntu 24.04 configured with --with-readline=editline, and I can reproduce the failure.

    From what I found, this appears to be a test assumption rather than a cmd.py bug. GNU readline emits the completed text contiguously in the raw PTY output, while libedit redraws the line using terminal control sequences (for example \x1b[10G) and only emits the remaining suffix (ello).

    The completion itself still succeeds: Cmd.default() receives the completed command and the test prints tab completion success. The failure is that the test currently expects b"hello" to appear contiguously in the raw transcript, which is not guaranteed with libedit.

    Unless anyone sees a better approach, I'm planning to prepare a small test-only PR that relaxes this readline-specific assertion while preserving the behavioral check that tab completion succeeded.

  2. self-assigned this
    on Sep 8, 2026
  3. added 2 commits that reference this issue on Sep 8, 2026
  4. added a commit that references this issue on Sep 12, 2026
  5. added a commit that references this issue on Sep 14, 2026
  6. added a commit that references this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions