[py-svn] py-trunk commit f780a7e071f2: ups, forgot to add a neccessary file.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Sep 9 15:37:16 CEST 2009


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1252503413 -7200
# Node ID f780a7e071f2b4a7a505dc8544c5c30229b6bc7c
# Parent d9e4ef1a07e999a0fc810516a76c56cb4f473707
ups, forgot to add a neccessary file.

--- /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



More information about the pytest-commit mailing list