#20323: Common TestSuite for MIP backends
-------------------------------------+-------------------------------------
Reporter: mkoeppe | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-7.2
Component: numerical | Resolution:
Keywords: lp | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/mkoeppe/common_testsuite_for_mip_backends|
d93b79857bdacc92a8a2a93155ab5f20bb0b1a8a
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by mkoeppe):
Replying to [comment:20 nthiery]:
> Or maybe putting the _test_* methods on the backends, with each
_test_method starting by creating a new instance.
Thanks Nicolas, Vincent, and Travis for your comments.
I agree, making changes to the object may be surprising to users who are
in the habit of running the testsuite on objects.
I have now converted the `_test_*` methods that were previously making
changes into methods that create a new instance.
(This is in line with what Nicolas suggests.)
All `_test_*` methods are now actually marked as classmethods, so these
methods don't even get access to the instance, so they can't modify it.
Here's an example.
{{{
@classmethod
def _test_add_linear_constraints(cls, tester=None, **options):
"""
Run tests on the method :meth:`.add_linear_constraints`.
TEST::
sage: from sage.numerical.backends.generic_backend import
GenericBackend
sage: p = GenericBackend()
sage: p._test_add_linear_constraints()
Traceback (most recent call last):
...
NotImplementedError
"""
p = cls() # fresh instance of the backend
if tester is None:
tester = p._tester(**options)
nrows_before = p.nrows()
nrows_added = 5
p.add_linear_constraints(nrows_added, None, 2)
nrows_after = p.nrows()
# Test correct number of rows
tester.assertEqual(nrows_after, nrows_before+nrows_added, "Added
the wrong number of rows")
# Test contents of the new rows are correct (sparse zero)
for i in range(nrows_before, nrows_after):
tester.assertEqual(p.row(i), ([], []))
tester.assertEqual(p.row_bounds(i), (None, 2.0))
}}}
Some of you suggested that the tests should be in a different file; but I
don't see how that would help. I would rather like to keep them as close
as possible to the definitions of the methods in `GenericBackend`; after
all the point of the new tests is to tighten the definition of the API of
the backends.
The nice thing about having these `_test_*` methods automatically
inherited by all concrete backends is that they cannot just "forget"
running the tests for them when it would be "convenient" to do so.
--
Ticket URL: <http://trac.sagemath.org/ticket/20323#comment:22>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.