Changes between Initial Version and Version 1 of Ticket #12920


Ignore:
Timestamp:
05/07/12 18:46:24 (9 years ago)
Author:
nthiery
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #12920

    • Property Status changed from new to needs_review
  • Ticket #12920 – Description

    initial v1  
     1``is_method`` / ``_test_from_is_method``: method wrappers to factor out code between ``is_bar`` and ``_test_bar`` methods
     2
     3From the documentation:
     4
     5The typical usecase for those wrappers is as follow: Consider a
     6category ``Foo`` with a subcategory ``Bar``.  ``Foo`` wants to
     7provide a method ``Foo.ParentMethods.is_bar`` such that, for ``F``
     8in ``Foo()``, ``F.is_bar()`` returns whether ``F`` satisfies all
     9the properties of ``Bar()``. The method ``is_bar`` is allowed to
     10assume that ``F`` indeed satisfies all the properties specified by
     11``Foo()``. It may decide to upgrade the category of ``F`` to
     12``Bar()``.
     13
     14``Bar`` itself wants to provide a method
     15``Bar.ParentMethod._test_bar`` which is supposed to do some
     16reasonable sanity checks on ``F`` to determine whether it
     17satisfies all the properties of ``Bar``. If yes, ``F._test_bla()``
     18should return None; otherwise it should raise some (hopefully
     19meaningful) assertion.  Note that ``Bar()`` will typically
     20override ``is_bar`` by a trivial method that always returns
     21``True``.
     22
     23The purpose of two decorators ``is_method`` and
     24``_test_method_from_is`` is to factor out the logic between the two
     25related methods ``F.is_bla()`` and ``F._test_bla()``. They take as
     26input a Python function ``is_bla(self, proof=False, **options)``.
     27This function should proceed as usual for a ``_test method`` (see
     28:class:`TestSuite`). If ``proof`` is ``True``, then the answer
     29should be provably correct. At the end, ``is_bla`` should return
     30``None``, or a category that will be used to refine the category
     31of ``F``.