2009-04-08 23:15:56 +08:00
|
|
|
pytest_plugins = '_pytest doctest pytester'.split()
|
|
|
|
|
2009-09-06 22:59:39 +08:00
|
|
|
rsyncdirs = ['conftest.py', 'py', 'doc', 'testing']
|
2009-03-19 05:24:42 +08:00
|
|
|
|
2007-02-09 07:43:27 +08:00
|
|
|
import py
|
2009-05-19 05:26:16 +08:00
|
|
|
def pytest_addoption(parser):
|
|
|
|
group = parser.addgroup("pylib", "py lib testing options")
|
|
|
|
group.addoption('--sshhost',
|
|
|
|
action="store", dest="sshhost", default=None,
|
|
|
|
help=("ssh xspec for ssh functional tests. "))
|
|
|
|
group.addoption('--gx',
|
|
|
|
action="append", dest="gspecs", default=None,
|
|
|
|
help=("add a global test environment, XSpec-syntax. "))
|
|
|
|
group.addoption('--runslowtests',
|
|
|
|
action="store_true", dest="runslowtests", default=False,
|
|
|
|
help=("run slow tests"))
|
2009-03-20 23:36:45 +08:00
|
|
|
|
2009-05-19 05:26:16 +08:00
|
|
|
def pytest_funcarg__specssh(request):
|
|
|
|
return getspecssh(request.config)
|
2009-10-02 22:58:57 +08:00
|
|
|
def getgspecs(config=None):
|
|
|
|
if config is None:
|
|
|
|
config = py.test.config
|
|
|
|
return [execnet.XSpec(spec)
|
|
|
|
for spec in config.getvalueorskip("gspecs")]
|
2009-03-20 23:36:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
# configuration information for tests
|
|
|
|
def getgspecs(config=None):
|
|
|
|
if config is None:
|
|
|
|
config = py.test.config
|
2009-10-02 22:58:57 +08:00
|
|
|
return [execnet.XSpec(spec)
|
2009-03-20 23:36:45 +08:00
|
|
|
for spec in config.getvalueorskip("gspecs")]
|
2009-02-27 18:18:27 +08:00
|
|
|
|
2009-03-20 23:36:45 +08:00
|
|
|
def getspecssh(config=None):
|
|
|
|
xspecs = getgspecs(config)
|
|
|
|
for spec in xspecs:
|
|
|
|
if spec.ssh:
|
|
|
|
if not py.path.local.sysfind("ssh"):
|
|
|
|
py.test.skip("command not found: ssh")
|
|
|
|
return spec
|
2009-03-21 00:28:14 +08:00
|
|
|
py.test.skip("need '--gx ssh=...'")
|
2007-02-09 07:43:27 +08:00
|
|
|
|
2009-03-20 23:36:45 +08:00
|
|
|
def getsocketspec(config=None):
|
|
|
|
xspecs = getgspecs(config)
|
|
|
|
for spec in xspecs:
|
|
|
|
if spec.socket:
|
|
|
|
return spec
|
2009-03-21 00:28:14 +08:00
|
|
|
py.test.skip("need '--gx socket=...'")
|
2009-07-31 20:21:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
def pytest_generate_tests(metafunc):
|
|
|
|
multi = getattr(metafunc.function, 'multi', None)
|
|
|
|
if multi is None:
|
|
|
|
return
|
|
|
|
assert len(multi.__dict__) == 1
|
|
|
|
for name, l in multi.__dict__.items():
|
|
|
|
for val in l:
|
|
|
|
metafunc.addcall(funcargs={name: val})
|