Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

How to update test files

Jeong, YunWon edited this page Dec 4, 2025 · 8 revisions

If you are looking for how to create a new test file, see How to contribute to RustPython using CPython's unit tests

Note

Unless stated otherwise, all commands needs to run from the RustPython directory.

Checkout CPython source code (initial setup)

This guide assumes that you have a copy of CPython on your machine, and for the rest of the guide we are going to assume that our CPython clone is at ~/cpython/.

If you don't have a copy of CPython you can get one by running:

git clone https://github.com/python/cpython.git ~/cpython

Note

We prefer to use a tagged version for the library updates, to do so run the following:

cd ~/cpython
git checkout v3.13.9

Updating the library

Is as simple as:

cp -a ~/cpython/Lib/base64.py Lib/

Important

While we try to avoid it as much as possible, we have some libraries that were patched by us. Run:

git diff

Search for RUSTPYTHON, and reapply the patches manually (if there are any)

Updating the tests

Because we have many # TODO: RUSTPYTHON marks in the test code, we have written our own tool to update test files.

The tool aims to automate the processes of transferring test marks (# TODO: RUSTPYTHON) from our current version of the test, to the upstream version from CPython.

Simply run:

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

The tool will:

  • Read the patches from Lib/test/test_os.py (--from)
  • Apply those patches to ~/cpython/Lib/test/test_os.py (--to)
  • Write the results to Lib/test/test_os.py (-o)

Important

We might have patched some tests by commenting unsupported syntax, or changing test behavior because of an implementation detail that needs to be reapplied manually.

Now the test file is updated, but we don't know if it passes yet - because there are newly added tests now.

Run the tests again:

cargo run -- Lib/test/test_os.py 

If there are failing tests, follow the instructions from How to contribute to RustPython using CPython's unit tests for the newly failing tests.

Done!

Please create a Pull Request with these changes. Thank you!

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.