Skip to content

Improved test coverage for codeop.py. - #154100

Open
vjabuilds wants to merge 5 commits into
python:mainfrom
vjabuilds:improve-codeop-test-coverage
Open

Improved test coverage for codeop.py.#154100
vjabuilds wants to merge 5 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.

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.

3 participants