Skip to content

test_scripts: run scripts from the active interpreter instead of PATH - #2168

Merged
zariiii9003 merged 1 commit into
hardbyte:mainfrom
zariiii9003:fix-test-scripts-path
Nov 29, 2026
Merged

zariiii9003 merged 1 commit into
hardbyte:mainfrom
zariiii9003:fix-test-scripts-path

Conversation

@zariiii9003

Copy link
Copy Markdown
Collaborator

Summary of Changes

  • test/test_scripts.py looked up python and the can_* console scripts on PATH. If the test interpreter's environment is not on PATH, the commands are not found or run a different installation.
  • -m commands now start with sys.executable.
  • Console scripts are resolved with shutil.which(name, path=sysconfig.get_path("scripts")). This also finds C:\PythonXY\Scripts\ on a non-venv Windows install and adds the .exe suffix, so shell=IS_WINDOWS and command.split() are no longer needed.
  • from .config import * is removed because IS_WINDOWS was its only use.

Related Issues / Pull Requests

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Other (please describe):

Checklist

  • I have followed the contribution guide.
  • I have added or updated tests as appropriate.
  • I have added or updated documentation as appropriate.
  • I have added a news fragment for towncrier.
  • All checks and tests pass (tox).

Additional Notes

Documentation and news fragment are not applicable: the change is test-only and not user-facing.

Reproduction, using only the test environment's interpreter without the venv on PATH:

env -i HOME=$HOME PATH=/usr/bin:/bin .tox/py/bin/python -m pytest test/test_scripts.py
  • main: 4 of 8 tests fail. Every test_do_commands_exist fails with FileNotFoundError: [Errno 2] No such file or directory: 'python'.
  • This PR: 8 of 8 pass. If a console script is missing, the test fails with FileNotFoundError: console script 'can_bridge' is not installed.

@zariiii9003
zariiii9003 merged commit 1932a3f into hardbyte:main Nov 29, 2026
25 of 26 checks passed
@zariiii9003
zariiii9003 deleted the fix-test-scripts-path branch November 29, 2026 22:11
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