[py] fix test discovery for pytest #15415
Merged
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.
User description
Motivation and Context
This PR fixes test discovery for pytest, since it was not configured correctly in
pyproject.toml
.Due to the naming convention of most of the Python tests, test discovery was not correctly finding tests to execute. You could only run tests by explicitly calling each test file, not by running the entire suite or directory.
For example... you could run
pytest py/test/selenium/webdriver/common/window_tests.py
just fine, but runningpytest py/test/selenium/webdriver/common
orpytest py/test/selenium
would run nothing.Without this fix, only 31 of the 1106 tests were able to be run!
(Note: this is only really evident when running
pytest
directly for local testing, since the bazel build tasks used for testing/CI call each test file explicitly and don't use test discovery)Before this change:
After this change:
Types of changes
Checklist
PR Type
Bug fix
Description
Fixed pytest test discovery by updating
python_files
inpyproject.toml
.Enabled discovery of files with
*_tests.py
naming convention.Improved test suite execution from 31 to 1106 tests.
Changes walkthrough 📝
pyproject.toml
Update pytest configuration for test discovery
py/pyproject.toml
*_tests.py
topython_files
for pytest discovery.