From 8ea2364039f16798b7fcf765a303f04221e3411e Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 9 Sep 2009 15:36:53 +0200 Subject: [PATCH] ups, forgot to add a neccessary file. --HG-- branch : trunk --- testing/execnet/conftest.py | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 testing/execnet/conftest.py diff --git a/testing/execnet/conftest.py b/testing/execnet/conftest.py new file mode 100644 index 000000000..6c14134d3 --- /dev/null +++ b/testing/execnet/conftest.py @@ -0,0 +1,46 @@ +import py + +def pytest_generate_tests(metafunc): + if 'gw' in metafunc.funcargnames: + if hasattr(metafunc.cls, 'gwtype'): + gwtypes = [metafunc.cls.gwtype] + else: + gwtypes = ['popen', 'socket', 'ssh'] + for gwtype in gwtypes: + metafunc.addcall(id=gwtype, param=gwtype) + +def pytest_funcarg__gw(request): + scope = "module" + if request.param == "popen": + return request.cached_setup( + setup=py.execnet.PopenGateway, + teardown=lambda gw: gw.exit(), + extrakey=request.param, + scope=scope) + elif request.param == "socket": + return request.cached_setup( + setup=setup_socket_gateway, + teardown=teardown_socket_gateway, + extrakey=request.param, + scope=scope) + elif request.param == "ssh": + return request.cached_setup( + setup=lambda: setup_ssh_gateway(request), + teardown=lambda gw: gw.exit(), + extrakey=request.param, + scope=scope) + +def setup_socket_gateway(): + proxygw = py.execnet.PopenGateway() + gw = py.execnet.SocketGateway.new_remote(proxygw, ("127.0.0.1", 0)) + gw.proxygw = proxygw + return gw + +def teardown_socket_gateway(gw): + gw.exit() + gw.proxygw.exit() + +def setup_ssh_gateway(request): + sshhost = request.getfuncargvalue('specssh').ssh + gw = py.execnet.SshGateway(sshhost) + return gw