Skip to content

Conversation

tobiasdiez
Copy link
Contributor

📚 Description

Thanks to the recent advantages around sage.all imports (thanks @mkoeppe), we can remove the global sage.all import for pytests. This means that all pytests run now without this global import, and also the collection of tests is way quicker.

Of course, for doctests invoked by pytest the all import is still needed, so it's moved into the corresponding fixture.

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • 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

@mkoeppe
Copy link
Contributor

mkoeppe commented May 2, 2023

That would a pleasant surprise if this already works. But where do we see what tests were actually run by pytest? I have the suspicion that it's not running tests, because of the namespace package issue; in https://github.com/sagemath/sage/actions/runs/4863120862/jobs/8670370254?pr=35598, it says

============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-7.3.1, pluggy-1.0.0
rootdir: /__w/sage/sage/src
configfile: tox.ini
plugins: mock-3.10.0
collected 0 items / 1 skipped

@tobiasdiez
Copy link
Contributor Author

It was actually an issue with the pytest collection (the skip call for pyx files made it skip all files). This is fixed now. However, there are a few failing tests. Do you have an idea why the import of pyscipopt and cvxpy fail?

@mkoeppe
Copy link
Contributor

mkoeppe commented May 4, 2023

They are not standard packages, so not installed

@mkoeppe
Copy link
Contributor

mkoeppe commented May 4, 2023

Since these tests never ran, I probably didn't add the magic to conditionalize the tests. Could you help with this?

@tobiasdiez
Copy link
Contributor Author

Okay, thanks. Was easy enough to fix. So this is ready for review again (the failing doctest seems unrelated).

@github-actions
Copy link

github-actions bot commented May 4, 2023

Documentation preview for this PR is ready! 🎉
Built with commit: 2085480

Copy link
Contributor

@mkoeppe mkoeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looking great. I've pushed a small change re the use of a variable from sage.env, which makes it better for downstream.

@tobiasdiez
Copy link
Contributor Author

Thanks for the review!

@vbraun vbraun merged commit 2096652 into sagemath:develop May 28, 2023
@tobiasdiez tobiasdiez deleted the pytest_allimport branch May 28, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants