Skip to content

Run the test modules with the interpreter running the test runner. - #802

Open
MohammedAlkindi wants to merge 5 commits into
google:masterfrom
MohammedAlkindi:fix/test-runner-interpreter
Open

MohammedAlkindi wants to merge 5 commits into
google:masterfrom
MohammedAlkindi:fix/test-runner-interpreter

Conversation

@MohammedAlkindi

@MohammedAlkindi MohammedAlkindi commented Aug 29, 2026 •

Copy link
Copy Markdown

run_tests.py launches each test module as ['python', '-m', test], which resolves python through PATH instead of using the interpreter running the runner. In a virtualenv that is not on PATH, the modules run under the system interpreter, where the requirements.txt packages are not installed, and all 59 fail with ModuleNotFoundError: No module named 'absl'.

The fix passes sys.executable instead, so each module runs under the interpreter that already imported glazier to discover it.

In a virtualenv built from requirements.txt (Windows 11, Python 3.13.13):

before: Success: 0 / Failure: 59
after:  Success: 51 / Failure: 8

The remaining 8 failures are pre-existing and only show up once the modules import. CI does not hit this because actions/setup-python puts its interpreter on PATH as python. A Linux virtualenv reproduces it too.

run_tests.py spawned each test module as ['python', '-m', test]. That resolves
'python' through PATH, which is not necessarily the interpreter running the
runner. Inside a virtualenv that was not activated on PATH, every module is
launched by the system interpreter instead, where the packages from
requirements.txt are not installed, and all 59 modules fail with
ModuleNotFoundError: No module named 'absl'.

Using sys.executable launches each module with the interpreter that imported
glazier to discover it, so the test modules see the environment the runner is
already using.

CI does not hit this because actions/setup-python puts the target interpreter
on PATH as 'python', making the two the same by construction.

This branch has not been deployed

No deployments
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.

1 participant