File: test_repevent.py

package info (click to toggle)
codespeak-lib 0.9.1-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,212 kB
  • ctags: 5,409
  • sloc: python: 33,390; ansic: 961; xml: 582; makefile: 90
file content (36 lines) | stat: -rw-r--r-- 1,065 bytes parent folder | download
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
36
""" test reporting functionality. """

import py
from py.__.test.rsession import repevent 

def test_wrapcall_ok():
    l = []
    def ok(x):
        return x+1
    i = repevent.wrapcall(l.append, ok, 1)
    assert i == 2
    assert len(l) == 2
    assert isinstance(l[0], repevent.CallStart) 
    assert isinstance(l[1], repevent.CallFinish) 
    assert repr(l[0]) 
    assert repr(l[1]) 

def test_wrapcall_exception():
    l = []
    def fail(x):
        raise ValueError
    py.test.raises(ValueError, "repevent.wrapcall(l.append, fail, 1)")
    assert len(l) == 2
    assert isinstance(l[0], repevent.CallStart) 
    assert isinstance(l[1], repevent.CallException) 

def test_reporter_methods_sanity():
    """ Checks if all the methods of reporter are sane
    """
    from py.__.test.rsession.rsession import RemoteReporter
    from py.__.test.rsession import repevent
    
    for method in dir(RemoteReporter):
        
        if method.startswith("report_") and method != "report_unknown":
            assert method[len('report_'):] in repevent.__dict__