parent
ee72091783
commit
3f31ed5742
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue