Skip to content

Add tool for easier test updates#6089

Merged
youknowone merged 34 commits intoRustPython:mainfrom
ShaharNaveh:auto-updater
Sep 7, 2025
Merged

Add tool for easier test updates#6089
youknowone merged 34 commits intoRustPython:mainfrom
ShaharNaveh:auto-updater

Conversation

@ShaharNaveh
Copy link
Copy Markdown
Contributor

@ShaharNaveh ShaharNaveh commented Aug 11, 2025

The idea is to have a file that defines which tests needs to be marked with what (expectedFailure, skipIf, etc..), and have a code that automatically applies those patches on a given test file.

This is a POC only, I have plans to make it more modular using argparse and some flags, but the general gist will remain the same.

This tool helps with updating test files from CPython.

You can run it like this:

./scripts/lib_updater.py --from Lib/test/foo.py --to ~/cpython/Lib/test/foo.py -o Lib/test/foo.py

to move the patches found in Lib/test/foo.py to ~/cpython/Lib/test/foo.py then write the contents back to Lib/test/foo.py (you can omit the -o arg to print the new contents to stdout)

You can also run it with:

./scripts/lib_updater.py --from Lib/test/foo.py --show-patches -o my_patches.json

To get a baseline of patches. You can alter the patches file with your favorite tool/script/etc and then reapply it with:

./scripts/lib_updater.py -p my_patches. json --to Lib/test/foo.py

cc: @youknowone @arihant2math @moreal @reactive-firewall would love to hear your feedback

ref: #5974


This PR also updates test_os.py from 3.13.7 btw

Summary by CodeRabbit

  • New Features
    • Adds a standalone CLI to analyze unittest tests and generate/apply structured patch blocks.
    • Can derive patches from source or load from JSON; includes a preview mode to show patches without applying.
    • Preserves indentation and insertion points, supports in-place updates or printing results, and emits wrapper entries for inherited tests.
    • Handles platform-specific conditions and warns about missing or unmatched test references.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants