[svn r63191] * remove "--exec"
* cleanup of options --HG-- branch : trunk
This commit is contained in:
parent
87de06a124
commit
fc14b038af
|
@ -17,7 +17,7 @@ def main(args=None):
|
|||
config.pytestplugins.do_unconfigure(config)
|
||||
raise SystemExit(exitstatus)
|
||||
except config.Error, e:
|
||||
py.std.sys.stderr.write("config ERROR: %s\n" %(e.args[0],))
|
||||
py.std.sys.stderr.write("ERROR: %s\n" %(e.args[0],))
|
||||
raise SystemExit(3)
|
||||
|
||||
def warn_about_missing_assertion():
|
||||
|
|
|
@ -221,7 +221,9 @@ class Config(object):
|
|||
if cls is None:
|
||||
from py.__.test.session import Session
|
||||
cls = Session
|
||||
return cls(self)
|
||||
session = cls(self)
|
||||
self.trace("instantiated session %r" % session)
|
||||
return session
|
||||
|
||||
def _reparse(self, args):
|
||||
""" this is used from tests that want to re-invoke parse(). """
|
||||
|
@ -253,11 +255,7 @@ class Config(object):
|
|||
def getxspecs(self):
|
||||
config = self
|
||||
if config.option.numprocesses:
|
||||
if config.option.executable:
|
||||
s = 'popen//python=%s' % config.option.executable
|
||||
else:
|
||||
s = 'popen'
|
||||
xspec = [s] * config.option.numprocesses
|
||||
xspec = ['popen'] * config.option.numprocesses
|
||||
else:
|
||||
xspec = config.option.xspec
|
||||
if not xspec:
|
||||
|
|
|
@ -57,30 +57,14 @@ class DSession(Session):
|
|||
MAXITEMSPERHOST = 15
|
||||
|
||||
def __init__(self, config):
|
||||
super(DSession, self).__init__(config=config)
|
||||
|
||||
self.queue = Queue.Queue()
|
||||
self.node2pending = {}
|
||||
self.item2node = {}
|
||||
if self.config.getvalue("executable") and \
|
||||
not self.config.getvalue("numprocesses"):
|
||||
self.config.option.numprocesses = 1
|
||||
super(DSession, self).__init__(config=config)
|
||||
|
||||
def fixoptions(self):
|
||||
""" check, fix and determine conflicting options. """
|
||||
option = self.config.option
|
||||
#if option.runbrowser and not option.startserver:
|
||||
# #print "--runbrowser implies --startserver"
|
||||
# option.startserver = True
|
||||
if self.config.getvalue("dist_boxed") and option.dist:
|
||||
option.boxed = True
|
||||
# conflicting options
|
||||
if option.looponfailing and option.usepdb:
|
||||
raise ValueError, "--looponfailing together with --pdb not supported."
|
||||
if option.executable and option.usepdb:
|
||||
raise ValueError, "--exec together with --pdb not supported."
|
||||
if option.executable and not option.dist and not option.numprocesses:
|
||||
option.numprocesses = 1
|
||||
def pytest_configure(self, config):
|
||||
if self.config.getvalue("usepdb"):
|
||||
raise self.config.Error("--pdb does not work for distributed tests (yet).")
|
||||
try:
|
||||
self.config.getxspecs()
|
||||
except self.config.Error:
|
||||
|
|
|
@ -25,15 +25,6 @@ def dumpqueue(queue):
|
|||
print queue.get()
|
||||
|
||||
class TestDSession:
|
||||
def test_fixoptions(self, testdir):
|
||||
config = testdir.parseconfig("--exec=xxx")
|
||||
config.pytestplugins.do_configure(config)
|
||||
config.initsession().fixoptions()
|
||||
assert config.option.numprocesses == 1
|
||||
config = testdir.parseconfig("--exec=xxx", '-n3')
|
||||
config.initsession().fixoptions()
|
||||
assert config.option.numprocesses == 3
|
||||
|
||||
def test_add_remove_node(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
rep = run(item)
|
||||
|
|
|
@ -49,17 +49,6 @@ class LoopState:
|
|||
class RemoteControl(object):
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
self._setexecutable()
|
||||
|
||||
def _setexecutable(self):
|
||||
# XXX --exec logic should go to DSession
|
||||
name = self.config.option.executable
|
||||
if name is None:
|
||||
executable = py.std.sys.executable
|
||||
else:
|
||||
executable = py.path.local.sysfind(name)
|
||||
assert executable is not None, executable
|
||||
self.executable = executable
|
||||
|
||||
def trace(self, *args):
|
||||
if self.config.option.debug:
|
||||
|
@ -67,7 +56,7 @@ class RemoteControl(object):
|
|||
print "RemoteControl:", msg
|
||||
|
||||
def initgateway(self):
|
||||
return py.execnet.PopenGateway(self.executable)
|
||||
return py.execnet.PopenGateway()
|
||||
|
||||
def setup(self, out=None):
|
||||
if out is None:
|
||||
|
@ -128,7 +117,6 @@ def slave_runsession(channel, config, fullwidth, hasmarkup):
|
|||
#config.option.session = None
|
||||
config.option.looponfailing = False
|
||||
config.option.usepdb = False
|
||||
config.option.executable = None
|
||||
trails = channel.receive()
|
||||
config.pytestplugins.do_configure(config)
|
||||
DEBUG("SLAVE: initsession()")
|
||||
|
|
|
@ -86,7 +86,7 @@ class DefaultPlugin:
|
|||
help="trace considerations of conftest.py files."),
|
||||
group._addoption('--nomagic',
|
||||
action="store_true", dest="nomagic", default=False,
|
||||
help="don't use assert reinterpretation and python traceback cutting. ")
|
||||
help="don't reinterpret asserts, no traceback cutting. ")
|
||||
group.addoption('--debug',
|
||||
action="store_true", dest="debug", default=False,
|
||||
help="generate and show debugging information.")
|
||||
|
@ -101,20 +101,9 @@ class DefaultPlugin:
|
|||
group.addoption('--rsyncdirs', dest="rsyncdirs", default=None, metavar="dir1,dir2,...",
|
||||
help="comma-separated list of directories to rsync. All those roots will be rsynced "
|
||||
"into a corresponding subdir on the remote sides. ")
|
||||
group._addoption('--xspec', '--tx', '-t', dest="xspec", action="append",
|
||||
group._addoption('--tx', dest="xspec", action="append",
|
||||
help=("add a test environment, specified in XSpec syntax. examples: "
|
||||
"--tx popen//python=python2.5 --tx socket=192.168.1.102"))
|
||||
group._addoption('--exec',
|
||||
action="store", dest="executable", default=None,
|
||||
help="python executable to run the tests with.")
|
||||
#group._addoption('-w', '--startserver',
|
||||
# action="store_true", dest="startserver", default=False,
|
||||
# help="starts local web server for displaying test progress.",
|
||||
# ),
|
||||
#group._addoption('-r', '--runbrowser',
|
||||
# action="store_true", dest="runbrowser", default=False,
|
||||
# help="run browser (implies --startserver)."
|
||||
# ),
|
||||
#group._addoption('--rest',
|
||||
# action='store_true', dest="restreport", default=False,
|
||||
# help="restructured text output reporting."),
|
||||
|
@ -122,6 +111,14 @@ class DefaultPlugin:
|
|||
def pytest_configure(self, config):
|
||||
self.setsession(config)
|
||||
self.loadplugins(config)
|
||||
self.fixoptions(config)
|
||||
|
||||
def fixoptions(self, config):
|
||||
if config.getvalue("usepdb"):
|
||||
if config.getvalue("looponfailing"):
|
||||
raise config.Error("--pdb incompatible with --looponfailing.")
|
||||
if config.getvalue("dist"):
|
||||
raise config.Error("--pdb incomptaible with distributed testing.")
|
||||
|
||||
def loadplugins(self, config):
|
||||
for name in config.getvalue("plugin"):
|
||||
|
@ -133,12 +130,13 @@ class DefaultPlugin:
|
|||
if val("collectonly"):
|
||||
from py.__.test.session import Session
|
||||
config.setsessionclass(Session)
|
||||
elif val("looponfailing"):
|
||||
from py.__.test.looponfail.remote import LooponfailingSession
|
||||
config.setsessionclass(LooponfailingSession)
|
||||
elif val("numprocesses") or val("dist") or val("executable"):
|
||||
from py.__.test.dsession.dsession import DSession
|
||||
config.setsessionclass(DSession)
|
||||
else:
|
||||
if val("looponfailing"):
|
||||
from py.__.test.looponfail.remote import LooponfailingSession
|
||||
config.setsessionclass(LooponfailingSession)
|
||||
elif val("numprocesses") or val("dist"):
|
||||
from py.__.test.dsession.dsession import DSession
|
||||
config.setsessionclass(DSession)
|
||||
|
||||
def pytest_item_makereport(self, item, excinfo, when, outerr):
|
||||
from py.__.test import event
|
||||
|
@ -156,11 +154,7 @@ def test_implied_different_sessions(tmpdir):
|
|||
assert x('--dist') == 'DSession'
|
||||
assert x('-n3') == 'DSession'
|
||||
assert x('-f') == 'LooponfailingSession'
|
||||
assert x('--exec=x') == 'DSession'
|
||||
assert x('-f', '--exec=x') == 'LooponfailingSession'
|
||||
assert x('--dist', '--exec=x', '--collectonly') == 'Session'
|
||||
|
||||
|
||||
assert x('--dist', '--collectonly') == 'Session'
|
||||
|
||||
def test_generic(plugintester):
|
||||
plugintester.apicheck(DefaultPlugin)
|
||||
|
@ -176,3 +170,17 @@ def test_plugin_already_exists(testdir):
|
|||
config = testdir.parseconfig("-p", "default")
|
||||
assert config.option.plugin == ['default']
|
||||
config.pytestplugins.do_configure(config)
|
||||
|
||||
def test_conflict_options():
|
||||
def check_conflict_option(opts):
|
||||
print "testing if options conflict:", " ".join(opts)
|
||||
config = py.test.config._reparse(opts)
|
||||
py.test.raises(config.Error,
|
||||
"config.pytestplugins.do_configure(config)")
|
||||
conflict_options = (
|
||||
'--looponfailing --pdb',
|
||||
'--dist --pdb',
|
||||
)
|
||||
for spec in conflict_options:
|
||||
opts = spec.split()
|
||||
yield check_conflict_option, opts
|
||||
|
|
|
@ -26,18 +26,6 @@ class Session(object):
|
|||
self._nomatch = False
|
||||
self.shouldstop = False
|
||||
|
||||
def fixoptions(self):
|
||||
""" check, fix and determine conflicting options. """
|
||||
option = self.config.option
|
||||
#if option.runbrowser and not option.startserver:
|
||||
# #print "--runbrowser implies --startserver"
|
||||
# option.startserver = True
|
||||
# conflicting options
|
||||
if option.looponfailing and option.usepdb:
|
||||
raise ValueError, "--looponfailing together with --pdb not supported."
|
||||
if option.executable and option.usepdb:
|
||||
raise ValueError, "--exec together with --pdb not supported."
|
||||
|
||||
def genitems(self, colitems, keywordexpr=None):
|
||||
""" yield Items from iterating over the given colitems. """
|
||||
while colitems:
|
||||
|
|
|
@ -14,7 +14,7 @@ class TestPyTest:
|
|||
result = testdir.runpytest(testdir.tmpdir)
|
||||
assert result.ret != 0
|
||||
assert result.stderr.fnmatch_lines([
|
||||
'config ERROR: hello'
|
||||
'*ERROR: hello'
|
||||
])
|
||||
|
||||
def test_basetemp(self, testdir):
|
||||
|
|
|
@ -67,22 +67,6 @@ class TestConfigCmdlineParsing:
|
|||
config = py.test.config._reparse([tmpdir])
|
||||
py.test.raises(AssertionError, "config.parse([])")
|
||||
|
||||
def test_conflict_options(self):
|
||||
def check_conflict_option(opts):
|
||||
print "testing if options conflict:", " ".join(opts)
|
||||
config = py.test.config._reparse(opts)
|
||||
py.test.raises((ValueError, SystemExit), """
|
||||
config.initsession()
|
||||
""")
|
||||
py.test.skip("check on conflict options")
|
||||
conflict_options = (
|
||||
'--looponfailing --pdb',
|
||||
'--dist --pdb',
|
||||
'--exec=%s --pdb' % (py.std.sys.executable,),
|
||||
)
|
||||
for spec in conflict_options:
|
||||
opts = spec.split()
|
||||
yield check_conflict_option, opts
|
||||
|
||||
class TestConfigTmpdir:
|
||||
def test_getbasetemp(self, testdir):
|
||||
|
@ -250,22 +234,6 @@ class TestOptionEffects:
|
|||
config = py.test.config._reparse([testdir.tmpdir])
|
||||
assert not config.option.boxed
|
||||
|
||||
def test_boxed_option_from_conftest(self, testdir):
|
||||
tmpdir = testdir.tmpdir.ensure("subdir", dir=1)
|
||||
tmpdir.join("conftest.py").write(py.code.Source("""
|
||||
dist_boxed = True
|
||||
"""))
|
||||
config = py.test.config._reparse(['--dist', tmpdir])
|
||||
config.initsession()
|
||||
assert config.option.boxed
|
||||
|
||||
def test_boxed_option_from_conftest(self, testdir):
|
||||
testdir.makepyfile(conftest="dist_boxed=False")
|
||||
config = py.test.config._reparse([testdir.tmpdir, '--box'])
|
||||
assert config.option.boxed
|
||||
config.initsession()
|
||||
assert config.option.boxed
|
||||
|
||||
def test_config_iocapturing(self, testdir):
|
||||
config = testdir.parseconfig(testdir.tmpdir)
|
||||
assert config.getvalue("conf_iocapture")
|
||||
|
|
Loading…
Reference in New Issue