Skip to content

gh-154007: Improve test coverage for the shlex module#154009

Open
caseneuve wants to merge 1 commit into
python:mainfrom
caseneuve:154007-improve-shlex-test-coverage
Open

gh-154007: Improve test coverage for the shlex module#154009
caseneuve wants to merge 1 commit into
python:mainfrom
caseneuve:154007-improve-shlex-test-coverage

Conversation

@caseneuve

@caseneuve caseneuve commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Raises statement coverage of Lib/shlex.py from 67% to 91%.

Intentionally left out:

  • _print_tokens: only reachable via python -m shlex, not public API
  • A few break/continue branches deep in read_token()

Closes #154007.

Comment thread Lib/test/test_shlex.py
s.push_token(tok)
mock_print.assert_called_once_with(f"shlex: pushing token {tok!r}")

def testPushSourceString(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this already be covered by e.g. testPushToken?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It exercises the debug path, originally I had one test setting debug, then split into 2 as there was a big gap in testing debug paths (without this one we go 91% -> 90%).

Comment thread Lib/test/test_shlex.py Outdated
Comment thread Lib/test/test_shlex.py Outdated
Comment thread Lib/test/test_shlex.py Outdated
Comment thread Lib/test/test_shlex.py Outdated
@caseneuve
caseneuve force-pushed the 154007-improve-shlex-test-coverage branch from 8afc311 to cf4df39 Compare July 19, 2026 11:00
@caseneuve
caseneuve requested a review from tomasr8 July 19, 2026 11:00
@caseneuve
caseneuve force-pushed the 154007-improve-shlex-test-coverage branch from cf4df39 to 8fa77b3 Compare July 19, 2026 11:03
@caseneuve
caseneuve force-pushed the 154007-improve-shlex-test-coverage branch from 8fa77b3 to 9b33e5c Compare July 19, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Improve test coverage for the shlex module

2 participants