[svn r37723] Add a test

--HG--
branch : trunk
This commit is contained in:
fijal 2007-02-01 12:59:47 +01:00
parent ee72091783
commit 3f31ed5742
1 changed files with 49 additions and 1 deletions

View File

@ -3,7 +3,7 @@ import py
import example1
from py.__.test.rsession.executor import RunExecutor, BoxExecutor,\
AsyncExecutor
AsyncExecutor, ApigenExecutor
from py.__.test.rsession.outcome import ReprOutcome
from py.__.test.rsession.testing.test_slave import funcprint_spec, \
funcprintfail_spec
@ -120,3 +120,51 @@ def test_cont_executor():
outcome = ReprOutcome(outcome_repr)
assert not outcome.passed
assert outcome.stdout.find("samfing elz") != -1
def test_apigen_executor():
class Tracer(object):
def __init__(self):
self.starts = 0
self.ends = 0
def start_tracing(self):
self.starts += 1
def end_tracing(self):
self.ends += 1
tmpdir = py.test.ensuretemp("apigen_executor")
tmpdir.ensure("__init__.py")
tmpdir.ensure("test_one.py").write(py.code.Source("""
def g():
pass
def test_1():
g()
class TestX(object):
def setup_method(self, m):
self.ttt = 1
def test_one(self):
self.ttt += 1
def test_raise(self):
1/0
"""))
rootcol = py.test.collect.Directory(tmpdir)
tracer = Tracer()
item = rootcol.getitembynames("test_one.py/test_1")
ex = ApigenExecutor(item, config=config)
out1 = ex.execute(tracer)
item = rootcol.getitembynames("test_one.py/TestX/()/test_one")
ex = ApigenExecutor(item, config=config)
out2 = ex.execute(tracer)
item = rootcol.getitembynames("test_one.py/TestX/()/test_raise")
ex = ApigenExecutor(item, config=config)
out3 = ex.execute(tracer)
assert tracer.starts == 3
assert tracer.ends == 3
assert out1.passed
assert out2.passed
assert not out3.passed