-
-
Notifications
You must be signed in to change notification settings - Fork 673
Description
sage.numerical.backends
provides an opportunity to study use of pytest
as a replacement for TestSuite
(proposed in #30738) in a small self-contained codebase.
GenericBackend
defines an API and a small number of _test_
methods to check that the API is implemented correctly by the backend implementations. We do this at the example of _test_ncols_nonnegative
, leaving the other test methods for follow-up tickets.
Important design constraint:
- The testing framework must be extensible by user-defined classes (or classes from separately installed Python packages - such as the existing
sage_numerical_backends_coin
).
This is accomplished by introducing a new GenericBackendTests
class which defines the checks that should hold for all backend implementations. Then for each backend we introduce a class that derives from GenericBackendTests
and returns in the backend
test fixture the backend under test.
The pytests are now also executed in sage -t
after the doctests, e.g. bin/sage-runtests --verbose .
prints at the end
===================================================================================================================== test session starts ======================================================================================================================
platform linux -- Python 3.8.6, pytest-6.2.1, py-1.10.0, pluggy-0.13.1 -- /mnt/d/Programming/sage/src/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /mnt/d/Programming/sage/src
collected 10 items
sage/numerical/backends/cvxopt_backend_test.py::TestCVXOPTBackend::test_old_testsuite PASSED [ 10%]
sage/numerical/backends/cvxopt_backend_test.py::TestCVXOPTBackend::test_ncols_nonnegative PASSED [ 20%]
sage/numerical/backends/glpk_backend_test.py::TestGLPKBackend::test_ncols_nonnegative PASSED [ 30%]
sage/numerical/backends/glpk_backend_test.py::TestGLPKBackend::test_old_testsuite PASSED [ 40%]
sage/numerical/backends/glpk_exact_backend_test.py::TestGLPKExactBackend::test_ncols_nonnegative PASSED [ 50%]
sage/numerical/backends/glpk_exact_backend_test.py::TestGLPKExactBackend::test_old_testsuite PASSED [ 60%]
sage/numerical/backends/interactivelp_backend_test.py::TestInteractiveLPBackend::test_ncols_nonnegative PASSED [ 70%]
sage/numerical/backends/interactivelp_backend_test.py::TestInteractiveLPBackend::test_old_testsuite PASSED [ 80%]
sage/numerical/backends/ppl_backend_test.py::TestPPLBackend::test_ncols_nonnegative PASSED [ 90%]
sage/numerical/backends/ppl_backend_test.py::TestPPLBackend::test_old_testsuite PASSED [100%]
Depends on #30901
Depends on #31003
Depends on #30551
CC: @tobiasdiez @nthiery @tscrim @fchapoton @yuan-zhou
Component: doctest framework
Author: Tobias Diez, Matthias Koeppe
Branch: 0592226
Reviewer: Matthias Koeppe, Tobias Diez
Issue created by migration from https://trac.sagemath.org/ticket/31103