Changes between Version 2 and Version 4 of Ticket #12920


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

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #12920

    • Property Keywords days38 added
  • Ticket #12920 – Description

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