Reenable pytest again as part of sage -t#40446
Conversation
|
No idea about the failing tests in |
|
I guess the CI is invoking pytest via the |
Yes, pytest is called as part of |
|
Maybe you should retrigger the CI (e.g. by pushing an empty commit) just in case. |
sagemathgh-40474: Add pytest command to run tests in CI workflow <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Alternative to sagemath#40446. This time running pytest directly in the CI, instead of as part of `sage -t`. Removed one old test file that fails with meson since the sage cli is different then. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] 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 and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#40474 Reported by: Tobias Diez Reviewer(s):
|
Documentation preview for this PR (built with commit adcba7d; changes) is ready! 🎉 |
sage -t
|
This is now finally working. @user202729 @orlitzky please have a look. (CI now actually runs the pytests twice: once as we call |
|
Hm… I'm not entirely sure what this does, it would be useful to explain what exactly does pytest run on. (methods start with Though it's probably better to answer this in a docstring or rst file edit instead of a comment. |
|
It's the same as running pytest directly. So, essentially This PR also doesn't introduce anything new. The functionality to run pytest as part of sage -t is there for some time, it just got broken/disabled by moving conftest.py to the root directory. |
|
I'm not entirely sure that's the right thing to do. Previously Plus does it work only from sage root, or any directory? |
Yes only _test files are passed on to pytest if you specify a file. To cite from the code: |
|
The |
src/sage/doctest/__main__.py
Outdated
| # 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 |
There was a problem hiding this comment.
This is cute but we should probably use os.path.isdir() or not os.path.exists().
There was a problem hiding this comment.
I don't remember what the original was doing but it looks fine now.
There was a problem hiding this comment.
Okay, thanks. So this is ready to be merged or do you have any other suggestions/concerns?
There was a problem hiding this comment.
Yeah, let's do it, thanks.
There was a problem hiding this comment.
Thanks for the review!
|
Aside from that one small refactoring for clarity, this LGTM, but I'm not sure if we should keep the separate |
Both is fine with me. Maybe we revisit this later once more tests are converted to pytest? I also hope that in the not so far future we can simply use pytest to also run the doctests (#36981). |
sagemathgh-40446: Reenable pytest again as part of `sage -t` <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Pytest used to run on as part of `sage -t`, but this is no longer the case. Here, we reactivate it by removing some safe-guards that are no longer necessary as pytest is a standard package now. Moreover, a "runtime error" due to a changing dict in an iteration is fixed in sagemath@ae60cdadd52 234800ce20f13071b99842010d224. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] 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 and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#40446 Reported by: Tobias Diez Reviewer(s): Michael Orlitzky, Tobias Diez
Pytest used to run on as part of
sage -t, but this is no longer the case. Here, we reactivate it by removing some safe-guards that are no longer necessary as pytest is a standard package now.Moreover, a "runtime error" due to a changing dict in an iteration is fixed in ae60cda.
📝 Checklist
⌛ Dependencies