Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage.geometry.polyhedron: Replace use of TestSuite by pytest #31104

Open
mkoeppe opened this issue Dec 24, 2020 · 2 comments
Open

sage.geometry.polyhedron: Replace use of TestSuite by pytest #31104

mkoeppe opened this issue Dec 24, 2020 · 2 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 24, 2020

sage.geometry.polyhedron provides an opportunity to study use of pytest as a replacement for TestSuite (proposed in #30738) in a small self-contained codebase.

_test_ methods for Polyhedron_base were only recently introduced in tickets such as #29934.

Important design constraint:

  • The polyhedron objects that can be tested depend on the presence of optional packages / Python modules such as PyNormaliz.

CC: @tobiasdiez @nthiery @tscrim @kliem

Component: doctest framework

Issue created by migration from https://trac.sagemath.org/ticket/31104

@tobiasdiez
Copy link
Contributor

comment:1

There are over 90 calls of TestSuite in sage.geometry.polyhedron. Which of these tests should be replaced?

The polyhedron objects that can be tested depend on the presence of optional packages / Python modules such as PyNormaliz.

That's straightforward to implement using pytest's mark mechanism: https://docs.pytest.org/en/stable/example/markers.html. Question: should the tests on optional packages be automatically skipped if the optional package is not installed (mark.skipif) or do you want to have the option to include/exclude all tests depending on the optional package (e.g. add mark.pynormaliz to the test class/method and then select all tests relying on pyronmaliz with pytest -m pynormaliz or exclude them with pytest -m "not pynormaliz")? In the latter case, in which granularity (specific optional package, all optional packages)?

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Dec 25, 2020

comment:2

Replying to @tobiasdiez:

The polyhedron objects that can be tested depend on the presence of optional packages / Python modules such as PyNormaliz.

That's straightforward to implement using pytest's mark mechanism: https://docs.pytest.org/en/stable/example/markers.html.

Thanks for the pointer.

Question: should the tests on optional packages be automatically skipped if the optional package is not installed (mark.skipif) or do you want to have the option to include/exclude all tests depending on the optional package (e.g. add mark.pynormaliz to the test class/method and then select all tests relying on pyronmaliz with pytest -m pynormaliz or exclude them with pytest -m "not pynormaliz")?

Same as in the existing sage -t -- there's autodetection of packages/features, but the user can also pass --optional=.... to override. See sage.doctest.control (which will need adjustments also in the course of the modularization effort).

In fact, given that any feasible transition plan will necessarily have both TestSuite and pytest tests in the codebase for some time, we should probably invoke pytest either from the doctests, or from the doctesting control script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants