2009-10-30 03:10:05 +08:00
|
|
|
import py
|
|
|
|
|
2009-04-08 23:15:56 +08:00
|
|
|
pytest_plugins = '_pytest doctest pytester'.split()
|
|
|
|
|
2009-12-07 02:18:44 +08:00
|
|
|
collect_ignore = ['build', 'doc/_build']
|
|
|
|
|
2009-10-30 03:10:05 +08:00
|
|
|
|
|
|
|
rsyncdirs = ['conftest.py', 'bin', 'py', 'doc', 'testing']
|
|
|
|
try:
|
|
|
|
import execnet
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
rsyncdirs.append(str(py.path.local(execnet.__file__).dirpath()))
|
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):
|
2009-10-17 23:43:33 +08:00
|
|
|
group = parser.getgroup("pylib", "py lib testing options")
|
2009-05-19 05:26:16 +08:00
|
|
|
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-12-30 01:02:54 +08:00
|
|
|
def getgspecs(config):
|
2009-10-02 22:58:57 +08:00
|
|
|
return [execnet.XSpec(spec)
|
|
|
|
for spec in config.getvalueorskip("gspecs")]
|
2009-03-20 23:36:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
# configuration information for tests
|
2009-12-30 01:02:54 +08:00
|
|
|
def getgspecs(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-12-30 01:02:54 +08:00
|
|
|
def getspecssh(config):
|
2009-03-20 23:36:45 +08:00
|
|
|
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-12-30 01:02:54 +08:00
|
|
|
def getsocketspec(config):
|
2009-03-20 23:36:45 +08:00
|
|
|
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
|
2009-10-23 02:57:21 +08:00
|
|
|
assert len(multi.kwargs) == 1
|
|
|
|
for name, l in multi.kwargs.items():
|
2009-07-31 20:21:02 +08:00
|
|
|
for val in l:
|
|
|
|
metafunc.addcall(funcargs={name: val})
|