You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gh-35999: Run pytest for src tree if no filename is given
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->
This fixes the failure seen, for example,
https://github.com/sagemath/sage/actions/runs/5678761729/job/15389749593
?pr=35991
Note that the last failure message
```
local/var/lib/sage/venv-python3.8/lib/python3.8/site-
packages/matplotlib/tests/__init__.py:6: in <module>
raise IOError(
E OSError: The baseline image directory does not exist. This is most
likely because the test data is not installed. You may need to install
matplotlib from source to get the test data.
=========================== short test summary info
============================
ERROR - OSError: The baseline image directory does not exist. This is
most likely because the test data is not installed. You may need to
install matplotlib from source to get the test data.
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection
!!!!!!!!!!!!!!!!!!!!
============================== 1 error in 12.78s
===============================
Error: Process completed with exit code 2.
```
This is not a fault of matplotlib! The fault lies on our pytest, which
blindly runs all tests found in the directory tree under the root dir.
(matplotlib test files are supposed to run in a development install,
where the baseline image directory exists, but our install (SPKG) of
matplotlib is not a development install, and hence there's no baseline
image directory.)
So we need to stop pytest from running blind. The failure in the
incremental test workflow results from an error in `sage-runtests`. The
relevant lines are
```python
exit_code_pytest = 0
import pytest
pytest_options = []
if args.verbose:
pytest_options.append("-v")
# #31924: Do not run pytest on individual Python files unless
# they match the pytest file pattern. However, pass names
# of directories. We use 'not os.path.isfile(f)' for this so
that
# we do not silently hide typos.
filenames = [f for f in args.filenames
if f.endswith("_test.py") or not os.path.isfile(f)]
if filenames or not args.filenames: #
<------------------------------------ faulty line!
print(f"Running pytest on {filenames} with options
{pytest_options}")
exit_code_pytest = pytest.main(filenames + pytest_options)
if exit_code_pytest == 5:
# Exit code 5 means there were no test files, pass in
this case
exit_code_pytest = 0
```
Look at the faulty line. The condition test allows pytest run without
explicit filenames. This results in running pytest for all test files
found under the (sage) root dir. Hence pytest attempts to run tests in
matplotlib in `local/var/lib/sage/venv-python3.11/lib/python3.11/site-
packages/matplotlib/tests`.
The branch of this PR fixes the problem.
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->
- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
URL: #35999
Reported by: Kwankyu Lee
Reviewer(s): Kwankyu Lee, Matthias Köppe, Tobias Diez
0 commit comments