Check-in [e9eaa54434]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Removed an unused import. Added a test case for Failure.trap.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e9eaa54434167bdf1861ad6af019474277013cbe
User & Date: yusuke 2010-10-26 11:56:53
Context
2010-11-15
13:30
split changes into CHANGES.txt check-in: b989bdfa37 user: yusuke tags: trunk
2010-10-26
11:56
Removed an unused import. Added a test case for Failure.trap. check-in: e9eaa54434 user: yusuke tags: trunk
11:36
need docutils for testing purpose. check-in: 2adc03f838 user: yusuke tags: trunk
Changes

Changes to tests/test_deferred.py.

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

from gaedeferred import Deferred, Failure

def value(result, value):
    return value

def increase(result, value=1):
    return result + value








|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

from gaedeferred import Failure

def value(result, value):
    return value

def increase(result, value=1):
    return result + value

Added tests/test_failure.py.







































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import py

def raise_value_error(_):
    raise ValueError("an excepted value error")

def raise_key_error(_):
    raise KeyError("an excepted key error")

def trap_value_error(f):
    f.trap(ValueError)
    # ok

def trap_value_error_for_fail(f):
    f.trap(ValueError)
    py.test.fail("trap failed")

def trap_exception(f):
    f.trap(Exception)
    py.test.fail("trap failed")

def test_trap(context):
    d = context.deferred()
    d.next(raise_value_error)
    d.error(trap_value_error)
    d.error(trap_exception)
    d.error(py.test.fail)
    d.next(py.test.fail)
    context.defer(d.callback, None)

    d = context.deferred()
    d.next(raise_key_error)
    d.error(trap_value_error_for_fail)
    d.error(trap_exception)
    d.next(py.test.fail)
    context.defer(d.callback, None)