[svn r38029] Move funcxxxspec out of pylib itself.
--HG-- branch : trunk
This commit is contained in:
parent
4369d430c8
commit
8fd09aac24
|
@ -0,0 +1,54 @@
|
||||||
|
|
||||||
|
""" Support module for running tests
|
||||||
|
"""
|
||||||
|
|
||||||
|
import py
|
||||||
|
|
||||||
|
def func_source():
|
||||||
|
import py
|
||||||
|
import time
|
||||||
|
def funcpass():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def funcfail():
|
||||||
|
raise AssertionError("hello world")
|
||||||
|
|
||||||
|
def funcskip():
|
||||||
|
py.test.skip("skipped")
|
||||||
|
|
||||||
|
def funcprint():
|
||||||
|
print "samfing"
|
||||||
|
|
||||||
|
def funcprintfail():
|
||||||
|
print "samfing elz"
|
||||||
|
asddsa
|
||||||
|
|
||||||
|
def funcoptioncustom():
|
||||||
|
assert py.test.config.getvalue("custom")
|
||||||
|
|
||||||
|
def funchang():
|
||||||
|
import time
|
||||||
|
time.sleep(1000)
|
||||||
|
|
||||||
|
class BasicRsessionTest(object):
|
||||||
|
def setup_class(cls):
|
||||||
|
tmptop = py.test.ensuretemp("test_suite")
|
||||||
|
name = cls.__name__
|
||||||
|
tmpdir = tmptop.ensure(name, dir=1)
|
||||||
|
source = py.code.Source(func_source)[1:].deindent()
|
||||||
|
tmpdir.ensure("test_one.py").write(source)
|
||||||
|
tmpdir.ensure("__init__.py")
|
||||||
|
cls.rootdir = tmpdir
|
||||||
|
cls.config = py.test.config._reparse([cls.rootdir])
|
||||||
|
cls.rootcol = cls.config._getcollector(tmpdir)
|
||||||
|
#cls.rootcol._config = cls.config
|
||||||
|
BASE = "test_one.py/"
|
||||||
|
cls.funcpass_spec = (BASE + "funcpass").split("/")
|
||||||
|
cls.funcfail_spec = (BASE + "funcfail").split("/")
|
||||||
|
cls.funcskip_spec = (BASE + "funcskip").split("/")
|
||||||
|
cls.funcprint_spec = (BASE + "funcprint").split("/")
|
||||||
|
cls.funcprintfail_spec = (BASE + "funcprintfail").split("/")
|
||||||
|
cls.funcoptioncustom_spec = (BASE + "funcoptioncustom").split("/")
|
||||||
|
cls.funchang_spec = (BASE + "funchang").split("/")
|
||||||
|
cls.mod_spec = BASE[:-1].split("/")
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
from py.__.test.rsession.slave import SlaveNode, slave_main, setup, PidInfo
|
from py.__.test.rsession.slave import SlaveNode, slave_main, setup, PidInfo
|
||||||
from py.__.test.rsession.outcome import ReprOutcome
|
from py.__.test.rsession.outcome import ReprOutcome
|
||||||
import py, sys
|
import py, sys
|
||||||
|
from py.__.test.rsession.testing.runtest import BasicRsessionTest
|
||||||
|
|
||||||
modlevel = []
|
modlevel = []
|
||||||
import os
|
import os
|
||||||
|
@ -10,108 +11,69 @@ import os
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
py.test.skip("rsession is unsupported on Windows.")
|
py.test.skip("rsession is unsupported on Windows.")
|
||||||
|
|
||||||
def setup_module(module):
|
|
||||||
module.tmpdir = py.test.ensuretemp(module.__name__)
|
|
||||||
module.rootdir = py.path.local(py.__file__).dirpath().dirpath()
|
|
||||||
module.rootcol = py.test.collect.Directory(rootdir)
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
# inlined testing functions used below
|
|
||||||
def funcpass():
|
|
||||||
pass
|
|
||||||
|
|
||||||
def funcfail():
|
|
||||||
raise AssertionError("hello world")
|
|
||||||
|
|
||||||
def funcskip():
|
|
||||||
py.test.skip("skipped")
|
|
||||||
|
|
||||||
def funcprint():
|
|
||||||
print "samfing"
|
|
||||||
|
|
||||||
def funcprintfail():
|
|
||||||
print "samfing elz"
|
|
||||||
asddsa
|
|
||||||
|
|
||||||
def funcoptioncustom():
|
|
||||||
assert py.test.config.getvalue("custom")
|
|
||||||
|
|
||||||
def funchang():
|
|
||||||
import time
|
|
||||||
time.sleep(1000)
|
|
||||||
|
|
||||||
BASE = "py/test/rsession/testing/test_slave.py/"
|
|
||||||
funcpass_spec = (BASE + "funcpass").split("/")
|
|
||||||
funcfail_spec = (BASE + "funcfail").split("/")
|
|
||||||
funcskip_spec = (BASE + "funcskip").split("/")
|
|
||||||
funcprint_spec = (BASE + "funcprint").split("/")
|
|
||||||
funcprintfail_spec = (BASE + "funcprintfail").split("/")
|
|
||||||
funcoptioncustom_spec = (BASE + "funcoptioncustom").split("/")
|
|
||||||
funchang_spec = (BASE + "funchang").split("/")
|
|
||||||
mod_spec = BASE[:-1].split("/")
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
from py.__.test.rsession.executor import RunExecutor
|
from py.__.test.rsession.executor import RunExecutor
|
||||||
|
|
||||||
def gettestnode():
|
class TestSlave(BasicRsessionTest):
|
||||||
config = py.test.config._reparse([rootdir])
|
def gettestnode(self):
|
||||||
pidinfo = PidInfo()
|
pidinfo = PidInfo()
|
||||||
node = SlaveNode(config, pidinfo, executor=RunExecutor)
|
node = SlaveNode(self.config, pidinfo, executor=RunExecutor)
|
||||||
return node
|
return node
|
||||||
|
|
||||||
def test_slave_run_passing():
|
def test_slave_run_passing(self):
|
||||||
node = gettestnode()
|
node = self.gettestnode()
|
||||||
item = rootcol._getitembynames(funcpass_spec)
|
item = self.rootcol._getitembynames(self.funcpass_spec)
|
||||||
outcome = node.execute(item._get_collector_trail())
|
outcome = node.execute(item._get_collector_trail())
|
||||||
assert outcome.passed
|
assert outcome.passed
|
||||||
assert not outcome.setupfailure
|
assert not outcome.setupfailure
|
||||||
|
|
||||||
ser = outcome.make_repr()
|
ser = outcome.make_repr()
|
||||||
reproutcome = ReprOutcome(ser)
|
reproutcome = ReprOutcome(ser)
|
||||||
assert reproutcome.passed
|
assert reproutcome.passed
|
||||||
assert not reproutcome.setupfailure
|
assert not reproutcome.setupfailure
|
||||||
|
|
||||||
def test_slave_run_failing():
|
def test_slave_run_failing(self):
|
||||||
node = gettestnode()
|
node = self.gettestnode()
|
||||||
item = rootcol._getitembynames(funcfail_spec)
|
item = self.rootcol._getitembynames(self.funcfail_spec)
|
||||||
outcome = node.execute(item._get_collector_trail())
|
outcome = node.execute(item._get_collector_trail())
|
||||||
assert not outcome.passed
|
assert not outcome.passed
|
||||||
assert not outcome.setupfailure
|
assert not outcome.setupfailure
|
||||||
assert len(outcome.excinfo.traceback) == 1
|
assert len(outcome.excinfo.traceback) == 1
|
||||||
assert outcome.excinfo.traceback[-1].frame.code.name == 'funcfail'
|
assert outcome.excinfo.traceback[-1].frame.code.name == 'funcfail'
|
||||||
|
|
||||||
ser = outcome.make_repr()
|
ser = outcome.make_repr()
|
||||||
reproutcome = ReprOutcome(ser)
|
reproutcome = ReprOutcome(ser)
|
||||||
assert not reproutcome.passed
|
assert not reproutcome.passed
|
||||||
assert not reproutcome.setupfailure
|
assert not reproutcome.setupfailure
|
||||||
assert reproutcome.excinfo
|
assert reproutcome.excinfo
|
||||||
|
|
||||||
def test_slave_run_skipping():
|
def test_slave_run_skipping(self):
|
||||||
node = gettestnode()
|
node = self.gettestnode()
|
||||||
item = rootcol._getitembynames(funcskip_spec)
|
item = self.rootcol._getitembynames(self.funcskip_spec)
|
||||||
outcome = node.execute(item._get_collector_trail())
|
outcome = node.execute(item._get_collector_trail())
|
||||||
assert not outcome.passed
|
assert not outcome.passed
|
||||||
assert outcome.skipped
|
assert outcome.skipped
|
||||||
|
|
||||||
ser = outcome.make_repr()
|
ser = outcome.make_repr()
|
||||||
reproutcome = ReprOutcome(ser)
|
reproutcome = ReprOutcome(ser)
|
||||||
assert not reproutcome.passed
|
assert not reproutcome.passed
|
||||||
assert reproutcome.skipped
|
assert reproutcome.skipped
|
||||||
|
|
||||||
def test_slave_run_failing_wrapped():
|
def test_slave_run_failing_wrapped(self):
|
||||||
node = gettestnode()
|
node = self.gettestnode()
|
||||||
item = rootcol._getitembynames(funcfail_spec)
|
item = self.rootcol._getitembynames(self.funcfail_spec)
|
||||||
repr_outcome = node.run(item._get_collector_trail())
|
repr_outcome = node.run(item._get_collector_trail())
|
||||||
outcome = ReprOutcome(repr_outcome)
|
outcome = ReprOutcome(repr_outcome)
|
||||||
assert not outcome.passed
|
assert not outcome.passed
|
||||||
assert not outcome.setupfailure
|
assert not outcome.setupfailure
|
||||||
assert outcome.excinfo
|
assert outcome.excinfo
|
||||||
|
|
||||||
def test_slave_run_different_stuff():
|
def test_slave_run_different_stuff(self):
|
||||||
node = gettestnode()
|
py.test.skip("XXX not this way")
|
||||||
node.run(rootcol._getitembynames("py doc log.txt".split()).
|
node = self.gettestnode()
|
||||||
_get_collector_trail())
|
node.run(self.rootcol._getitembynames("py doc log.txt".split()).
|
||||||
|
_get_collector_trail())
|
||||||
|
|
||||||
def test_pidinfo():
|
def test_pidinfo():
|
||||||
if not hasattr(os, 'fork') or not hasattr(os, 'waitpid'):
|
if not hasattr(os, 'fork') or not hasattr(os, 'waitpid'):
|
||||||
|
|
Loading…
Reference in New Issue