make looponfailing a bit more robust against relative imports and changed directories - needs more work, probably.

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-12-29 18:41:24 +01:00
parent 79af98fc29
commit c348cec481
2 changed files with 6 additions and 20 deletions

View File

@ -62,22 +62,22 @@ class RemoteControl(object):
if hasattr(self, 'gateway'):
raise ValueError("already have gateway %r" % self.gateway)
self.trace("setting up slave session")
old = self.config.topdir.chdir()
try:
self.gateway = self.initgateway()
finally:
old.chdir()
channel = self.gateway.remote_exec(source="""
self.gateway = self.initgateway()
channel = self.gateway.remote_exec("""
import os
from py.impl.test.dist.mypickle import PickleChannel
from py.impl.test.looponfail.remote import slave_runsession
chdir = channel.receive()
outchannel = channel.gateway.newchannel()
channel.send(outchannel)
channel = PickleChannel(channel)
os.chdir(chdir) # unpickling config uses cwd as topdir
config, fullwidth, hasmarkup = channel.receive()
import sys
sys.stdout = sys.stderr = outchannel.makefile('w')
slave_runsession(channel, config, fullwidth, hasmarkup)
""")
channel.send(str(self.config.topdir))
remote_outchannel = channel.receive()
def write(s):
out._file.write(s)

View File

@ -16,7 +16,6 @@ class TestConfigCmdlineParsing:
help='t value'),
)
""")
testdir.chdir()
config = testdir.reparseconfig(['-G', '17'])
assert config.option.gdest == 17
@ -46,19 +45,6 @@ class TestConfigCmdlineParsing:
config = testdir.parseconfig()
assert config.option.verbose
def test_config_cmdline_options_only_lowercase(self, testdir):
testdir.makepyfile(conftest="""
import py
Option = py.test.config.Option
options = py.test.config.addoptions("testing group",
Option('-g', '--glong', action="store", default=42,
type="int", dest="gdest", help="g value."),
)
""")
py.test.raises(ValueError, """
testdir.reparseconfig(['-g', '17'])
""")
def test_parsing_again_fails(self, testdir):
config = testdir.reparseconfig([testdir.tmpdir])
py.test.raises(AssertionError, "config.parse([])")