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
Testsuite: allow sharing code between is_bar and _test_bar methods #12920
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Changed keywords from none to days38 |
This comment has been minimized.
This comment has been minimized.
comment:5
Attachment: trac_12920-is_test_methods-nt.patch.gz |
comment:6
Needs to rebase on 5-11.beta3 (reject on unittest.py). The patch may definitely be useful. There are two things that I dislike.
you get something that you do not want to see here.
just to compare
which is how |
jdemeyer
changed the title
Decorators for sharing code between is_bar and _test_bar methods.
Testsuite: allow sharing code between is_bar and _test_bar methods
Jan 24, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is_method
/_test_from_is_method
: method wrappers to factor out code betweenis_bar
and_test_bar
methodsFrom the documentation:
The typical usecase for those wrappers is as follow: Consider a
category
Foo
with a subcategoryBar
.Foo
wants toprovide a method
Foo.ParentMethods.is_bar
such that, forF
in
Foo()
,F.is_bar()
returns whetherF
satisfies allthe properties of
Bar()
. The methodis_bar
is allowed toassume that
F
indeed satisfies all the properties specified byFoo()
. It may decide to upgrade the category ofF
toBar()
.Bar
itself wants to provide a methodBar.ParentMethod._test_bar
which is supposed to do somereasonable sanity checks on
F
to determine whether itsatisfies all the properties of
Bar
. If yes,F._test_bla()
should return None; otherwise it should raise some (hopefully
meaningful) assertion. Note that
Bar()
will typicallyoverride
is_bar
by a trivial method that always returnsTrue
.The purpose of two decorators
is_method
and_test_method_from_is
is to factor out the logic between the tworelated methods
F.is_bla()
andF._test_bla()
. They take asinput a Python function
is_bla(self, proof=False, **options)
.This function should proceed as usual for a
_test method
(see:class:
TestSuite
). Ifproof
isTrue
, then the answershould be provably correct. At the end,
is_bla
should returnNone
, or a category that will be used to refine the categoryof
F
.CC: @sagetrac-sage-combinat
Component: misc
Keywords: days38
Author: Nicolas M. Thiéry
Reviewer: Franco Saliola
Issue created by migration from https://trac.sagemath.org/ticket/12920
The text was updated successfully, but these errors were encountered: