add a test created from jgustak (but add the related env feature to execnet where it

is separately tested)
This commit is contained in:
holger krekel
2010-07-07 14:33:24 +02:00
parent fb31aa882d
commit 67e0cd463c
2 changed files with 28 additions and 4 deletions

View File

@@ -42,13 +42,13 @@ class MySetup:
eq = EventQueue(self.config.pluginmanager, self.queue) eq = EventQueue(self.config.pluginmanager, self.queue)
return eq.geteventargs(eventname, timeout=timeout) return eq.geteventargs(eventname, timeout=timeout)
def makenode(self, config=None): def makenode(self, config=None, xspec="popen"):
if config is None: if config is None:
testdir = self.request.getfuncargvalue("testdir") testdir = self.request.getfuncargvalue("testdir")
config = testdir.reparseconfig([]) config = testdir.reparseconfig([])
self.config = config self.config = config
self.queue = Queue() self.queue = Queue()
self.xspec = execnet.XSpec("popen") self.xspec = execnet.XSpec(xspec)
self.gateway = execnet.makegateway(self.xspec) self.gateway = execnet.makegateway(self.xspec)
self.id += 1 self.id += 1
self.gateway.id = str(self.id) self.gateway.id = str(self.id)
@@ -147,3 +147,26 @@ class TestMasterSlaveConnection:
for outcome in "passed failed skipped".split(): for outcome in "passed failed skipped".split():
rep = mysetup.geteventargs("pytest_runtest_logreport")['report'] rep = mysetup.geteventargs("pytest_runtest_logreport")['report']
assert getattr(rep, outcome) assert getattr(rep, outcome)
def test_send_one_with_env(self, testdir, mysetup, monkeypatch):
if execnet.XSpec("popen").env is None:
py.test.skip("requires execnet 1.0.7 or above")
monkeypatch.delenv('ENV1', raising=False)
monkeypatch.delenv('ENV2', raising=False)
monkeypatch.setenv('ENV3', 'var3')
item = testdir.getitem("""
def test_func():
import os
# ENV1, ENV2 set by xspec; ENV3 inherited from parent process
assert os.getenv('ENV2') == 'var2'
assert os.getenv('ENV1') == 'var1'
assert os.getenv('ENV3') == 'var3'
""")
node = mysetup.makenode(item.config,
xspec="popen//env:ENV1=var1//env:ENV2=var2")
node.send(item)
kwargs = mysetup.geteventargs("pytest_runtest_logreport")
rep = kwargs['report']
assert rep.passed

View File

@@ -9,17 +9,18 @@ sdistsrc={distshare}/pytest-xdist-**LATEST**
changedir=testing changedir=testing
deps= deps=
{distshare}/py-**LATEST** {distshare}/py-**LATEST**
{distshare}/execnet-**LATEST**
commands= commands=
py.test -rsfxX --tools-on-path \ py.test -rsfxX --tools-on-path \
--junitxml={envlogdir}/junit-{envname}.xml [] --junitxml={envlogdir}/junit-{envname}.xml []
[testenv:py27] [testenv:py27]
basepython=python2.7 basepython=python2.7
deps=
{distshare}/py-**LATEST**
{distshare}/execnet-**LATEST**
[testenv:py26] [testenv:py26]
basepython=python2.6 basepython=python2.6
deps= deps=
{distshare}/py-**LATEST** {distshare}/py-**LATEST**
{distshare}/execnet-**LATEST**
pexpect pexpect
#[testenv:py26-py132] #[testenv:py26-py132]
#basepython=python2.6 #basepython=python2.6