Skip to content

Improved test coverage for codeop.py. - #154100

Merged
encukou merged 7 commits into
python:mainfrom
vjabuilds:improve-codeop-test-coverage
Jul 30, 2026
Merged

Improved test coverage for codeop.py.#154100
encukou merged 7 commits into
python:mainfrom
vjabuilds:improve-codeop-test-coverage

Conversation

@vjabuilds

Copy link
Copy Markdown
Contributor

Improved the test coverage for codeop.py.

  • Ported existing tests to cover both the CommandCompiler and Compile classes
  • Added a test that covers the case when PyCF_ONLY_AST is set
  • Added a test that covers the case when the compile method returns a code object with flags

* Ported existing tests to cover both the CommandCompiler and Compile classes
* Added tests that cover the case when PyCF_ONLY_AST is set
* Added tests that cover the case when the compile method returns a code object with flags
@encukou

encukou commented Jul 19, 2026

Copy link
Copy Markdown
Member

If a test with a for loop fails, the traceback doesn't include which iteration failed. It's hard to investigate what went wrong.
Could you switch to using subTest? Ideally via the @test.support.subTests helper like here:

@support.subTests(('arg', 'expected'), (

The setup can be done at the module level.

* Moved test set up to module scope
* Use subTests decorator to inject compiler parameter into tests
* Introduced new compiler parameter to assert* family of methods
* Used functools to maintain the same API for the assert* methods where applicable
@vjabuilds

Copy link
Copy Markdown
Contributor Author

Thanks a lot for the feedback! I've implemented the changes you proposed and pushed them to my branch, so feel free to take a look when you can.

@encukou encukou left a comment

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.

Thank you!

For the future: you don't need to push "Update branch", unless there are merge conflicts.

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Sprint Jul 30, 2026
@encukou
encukou merged commit 405daf5 into python:main Jul 30, 2026
51 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Sprint Jul 30, 2026
@encukou encukou added needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 30, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @vjabuilds for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @vjabuilds for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @vjabuilds and @encukou, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 405daf5328a1f9f8355ba76b0174b236364c2646 3.14

@bedevere-app

bedevere-app Bot commented Jul 30, 2026

Copy link
Copy Markdown

GH-154938 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.14 bugs and security fixes skip issue skip news sprint tests Tests in the Lib/test dir

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants