Run the test modules with the interpreter running the test runner. - #802
Open
MohammedAlkindi wants to merge 2 commits into
Open
Run the test modules with the interpreter running the test runner.#802MohammedAlkindi wants to merge 2 commits into
MohammedAlkindi wants to merge 2 commits into
Conversation
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
run_tests.pyspawns each test module as['python', '-m', test]. That resolvespythonthrough PATH rather than using the interpreter running the runner. Inside a virtualenv that is not activated on PATH, every module is launched by the system interpreter instead, where the packages fromrequirements.txtare not installed, and all 59 modules fail withModuleNotFoundError: No module named 'absl'.sys.executablelaunches each module with the interpreter that already importedglazierto discover it.Measured on Windows 11, Python 3.13.13, in a virtualenv built from
requirements.txt. Before:Success: 0/Failure: 59. After:Success: 51/Failure: 8.That this is interpreter resolution and not a broken environment: on the unpatched tree, running one module directly with the venv interpreter gives
Ran 15 tests ... OK, whilesubprocess.run(['python', ...])from that same interpreter resolves to the systempython.exeand raises theModuleNotFoundErrorabove.CI does not hit this because
actions/setup-pythonputs the target interpreter on PATH aspython, making the two the same by construction. The failure is not platform specific, and a Linux virtualenv reproduces it.The remaining 8 failures are pre-existing and unrelated. They only become observable once the modules import at all.