test_ok1/py/test/rsession/testing/test_report.py

37 lines
1.0 KiB
Python
Raw Normal View History

""" test reporting functionality. """
import py
from py.__.test.rsession import report
def test_wrapcall_ok():
l = []
def ok(x):
return x+1
i = report.wrapcall(l.append, ok, 1)
assert i == 2
assert len(l) == 2
assert isinstance(l[0], report.CallStart)
assert isinstance(l[1], report.CallFinish)
assert repr(l[0])
assert repr(l[1])
def test_wrapcall_exception():
l = []
def fail(x):
raise ValueError
py.test.raises(ValueError, "report.wrapcall(l.append, fail, 1)")
assert len(l) == 2
assert isinstance(l[0], report.CallStart)
assert isinstance(l[1], report.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 report
for method in dir(RemoteReporter):
if method.startswith("report_") and method != "report_unknown":
assert method[len('report_'):] in report.__dict__