[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)
|
config.pytestplugins.do_unconfigure(config)
|
||||||
raise SystemExit(exitstatus)
|
raise SystemExit(exitstatus)
|
||||||
except config.Error, e:
|
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)
|
raise SystemExit(3)
|
||||||
|
|
||||||
def warn_about_missing_assertion():
|
def warn_about_missing_assertion():
|
||||||
|
|
|
@ -221,7 +221,9 @@ class Config(object):
|
||||||
if cls is None:
|
if cls is None:
|
||||||
from py.__.test.session import Session
|
from py.__.test.session import Session
|
||||||
cls = Session
|
cls = Session
|
||||||
return cls(self)
|
session = cls(self)
|
||||||
|
self.trace("instantiated session %r" % session)
|
||||||
|
return session
|
||||||
|
|
||||||
def _reparse(self, args):
|
def _reparse(self, args):
|
||||||
""" this is used from tests that want to re-invoke parse(). """
|
""" this is used from tests that want to re-invoke parse(). """
|
||||||
|
@ -253,11 +255,7 @@ class Config(object):
|
||||||
def getxspecs(self):
|
def getxspecs(self):
|
||||||
config = self
|
config = self
|
||||||
if config.option.numprocesses:
|
if config.option.numprocesses:
|
||||||
if config.option.executable:
|
xspec = ['popen'] * config.option.numprocesses
|
||||||
s = 'popen//python=%s' % config.option.executable
|
|
||||||
else:
|
|
||||||
s = 'popen'
|
|
||||||
xspec = [s] * config.option.numprocesses
|
|
||||||
else:
|
else:
|
||||||
xspec = config.option.xspec
|
xspec = config.option.xspec
|
||||||
if not xspec:
|
if not xspec:
|
||||||
|
|
|
@ -57,30 +57,14 @@ class DSession(Session):
|
||||||
MAXITEMSPERHOST = 15
|
MAXITEMSPERHOST = 15
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
super(DSession, self).__init__(config=config)
|
|
||||||
|
|
||||||
self.queue = Queue.Queue()
|
self.queue = Queue.Queue()
|
||||||
self.node2pending = {}
|
self.node2pending = {}
|
||||||
self.item2node = {}
|
self.item2node = {}
|
||||||
if self.config.getvalue("executable") and \
|
super(DSession, self).__init__(config=config)
|
||||||
not self.config.getvalue("numprocesses"):
|
|
||||||
self.config.option.numprocesses = 1
|
|
||||||
|
|
||||||
def fixoptions(self):
|
def pytest_configure(self, config):
|
||||||
""" check, fix and determine conflicting options. """
|
if self.config.getvalue("usepdb"):
|
||||||
option = self.config.option
|
raise self.config.Error("--pdb does not work for distributed tests (yet).")
|
||||||
#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
|
|
||||||
try:
|
try:
|
||||||
self.config.getxspecs()
|
self.config.getxspecs()
|
||||||
except self.config.Error:
|
except self.config.Error:
|
||||||
|
|
|
@ -25,15 +25,6 @@ def dumpqueue(queue):
|
||||||
print queue.get()
|
print queue.get()
|
||||||
|
|
||||||
class TestDSession:
|
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):
|
def test_add_remove_node(self, testdir):
|
||||||
item = testdir.getitem("def test_func(): pass")
|
item = testdir.getitem("def test_func(): pass")
|
||||||
rep = run(item)
|
rep = run(item)
|
||||||
|
|
|
@ -49,17 +49,6 @@ class LoopState:
|
||||||
class RemoteControl(object):
|
class RemoteControl(object):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.config = 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):
|
def trace(self, *args):
|
||||||
if self.config.option.debug:
|
if self.config.option.debug:
|
||||||
|
@ -67,7 +56,7 @@ class RemoteControl(object):
|
||||||
print "RemoteControl:", msg
|
print "RemoteControl:", msg
|
||||||
|
|
||||||
def initgateway(self):
|
def initgateway(self):
|
||||||
return py.execnet.PopenGateway(self.executable)
|
return py.execnet.PopenGateway()
|
||||||
|
|
||||||
def setup(self, out=None):
|
def setup(self, out=None):
|
||||||
if out is None:
|
if out is None:
|
||||||
|
@ -128,7 +117,6 @@ def slave_runsession(channel, config, fullwidth, hasmarkup):
|
||||||
#config.option.session = None
|
#config.option.session = None
|
||||||
config.option.looponfailing = False
|
config.option.looponfailing = False
|
||||||
config.option.usepdb = False
|
config.option.usepdb = False
|
||||||
config.option.executable = None
|
|
||||||
trails = channel.receive()
|
trails = channel.receive()
|
||||||
config.pytestplugins.do_configure(config)
|
config.pytestplugins.do_configure(config)
|
||||||
DEBUG("SLAVE: initsession()")
|
DEBUG("SLAVE: initsession()")
|
||||||
|
|
|
@ -86,7 +86,7 @@ class DefaultPlugin:
|
||||||
help="trace considerations of conftest.py files."),
|
help="trace considerations of conftest.py files."),
|
||||||
group._addoption('--nomagic',
|
group._addoption('--nomagic',
|
||||||
action="store_true", dest="nomagic", default=False,
|
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',
|
group.addoption('--debug',
|
||||||
action="store_true", dest="debug", default=False,
|
action="store_true", dest="debug", default=False,
|
||||||
help="generate and show debugging information.")
|
help="generate and show debugging information.")
|
||||||
|
@ -101,20 +101,9 @@ class DefaultPlugin:
|
||||||
group.addoption('--rsyncdirs', dest="rsyncdirs", default=None, metavar="dir1,dir2,...",
|
group.addoption('--rsyncdirs', dest="rsyncdirs", default=None, metavar="dir1,dir2,...",
|
||||||
help="comma-separated list of directories to rsync. All those roots will be rsynced "
|
help="comma-separated list of directories to rsync. All those roots will be rsynced "
|
||||||
"into a corresponding subdir on the remote sides. ")
|
"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: "
|
help=("add a test environment, specified in XSpec syntax. examples: "
|
||||||
"--tx popen//python=python2.5 --tx socket=192.168.1.102"))
|
"--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',
|
#group._addoption('--rest',
|
||||||
# action='store_true', dest="restreport", default=False,
|
# action='store_true', dest="restreport", default=False,
|
||||||
# help="restructured text output reporting."),
|
# help="restructured text output reporting."),
|
||||||
|
@ -122,6 +111,14 @@ class DefaultPlugin:
|
||||||
def pytest_configure(self, config):
|
def pytest_configure(self, config):
|
||||||
self.setsession(config)
|
self.setsession(config)
|
||||||
self.loadplugins(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):
|
def loadplugins(self, config):
|
||||||
for name in config.getvalue("plugin"):
|
for name in config.getvalue("plugin"):
|
||||||
|
@ -133,12 +130,13 @@ class DefaultPlugin:
|
||||||
if val("collectonly"):
|
if val("collectonly"):
|
||||||
from py.__.test.session import Session
|
from py.__.test.session import Session
|
||||||
config.setsessionclass(Session)
|
config.setsessionclass(Session)
|
||||||
elif val("looponfailing"):
|
else:
|
||||||
from py.__.test.looponfail.remote import LooponfailingSession
|
if val("looponfailing"):
|
||||||
config.setsessionclass(LooponfailingSession)
|
from py.__.test.looponfail.remote import LooponfailingSession
|
||||||
elif val("numprocesses") or val("dist") or val("executable"):
|
config.setsessionclass(LooponfailingSession)
|
||||||
from py.__.test.dsession.dsession import DSession
|
elif val("numprocesses") or val("dist"):
|
||||||
config.setsessionclass(DSession)
|
from py.__.test.dsession.dsession import DSession
|
||||||
|
config.setsessionclass(DSession)
|
||||||
|
|
||||||
def pytest_item_makereport(self, item, excinfo, when, outerr):
|
def pytest_item_makereport(self, item, excinfo, when, outerr):
|
||||||
from py.__.test import event
|
from py.__.test import event
|
||||||
|
@ -156,11 +154,7 @@ def test_implied_different_sessions(tmpdir):
|
||||||
assert x('--dist') == 'DSession'
|
assert x('--dist') == 'DSession'
|
||||||
assert x('-n3') == 'DSession'
|
assert x('-n3') == 'DSession'
|
||||||
assert x('-f') == 'LooponfailingSession'
|
assert x('-f') == 'LooponfailingSession'
|
||||||
assert x('--exec=x') == 'DSession'
|
assert x('--dist', '--collectonly') == 'Session'
|
||||||
assert x('-f', '--exec=x') == 'LooponfailingSession'
|
|
||||||
assert x('--dist', '--exec=x', '--collectonly') == 'Session'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_generic(plugintester):
|
def test_generic(plugintester):
|
||||||
plugintester.apicheck(DefaultPlugin)
|
plugintester.apicheck(DefaultPlugin)
|
||||||
|
@ -176,3 +170,17 @@ def test_plugin_already_exists(testdir):
|
||||||
config = testdir.parseconfig("-p", "default")
|
config = testdir.parseconfig("-p", "default")
|
||||||
assert config.option.plugin == ['default']
|
assert config.option.plugin == ['default']
|
||||||
config.pytestplugins.do_configure(config)
|
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._nomatch = False
|
||||||
self.shouldstop = 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):
|
def genitems(self, colitems, keywordexpr=None):
|
||||||
""" yield Items from iterating over the given colitems. """
|
""" yield Items from iterating over the given colitems. """
|
||||||
while colitems:
|
while colitems:
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TestPyTest:
|
||||||
result = testdir.runpytest(testdir.tmpdir)
|
result = testdir.runpytest(testdir.tmpdir)
|
||||||
assert result.ret != 0
|
assert result.ret != 0
|
||||||
assert result.stderr.fnmatch_lines([
|
assert result.stderr.fnmatch_lines([
|
||||||
'config ERROR: hello'
|
'*ERROR: hello'
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_basetemp(self, testdir):
|
def test_basetemp(self, testdir):
|
||||||
|
|
|
@ -67,22 +67,6 @@ class TestConfigCmdlineParsing:
|
||||||
config = py.test.config._reparse([tmpdir])
|
config = py.test.config._reparse([tmpdir])
|
||||||
py.test.raises(AssertionError, "config.parse([])")
|
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:
|
class TestConfigTmpdir:
|
||||||
def test_getbasetemp(self, testdir):
|
def test_getbasetemp(self, testdir):
|
||||||
|
@ -250,22 +234,6 @@ class TestOptionEffects:
|
||||||
config = py.test.config._reparse([testdir.tmpdir])
|
config = py.test.config._reparse([testdir.tmpdir])
|
||||||
assert not config.option.boxed
|
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):
|
def test_config_iocapturing(self, testdir):
|
||||||
config = testdir.parseconfig(testdir.tmpdir)
|
config = testdir.parseconfig(testdir.tmpdir)
|
||||||
assert config.getvalue("conf_iocapture")
|
assert config.getvalue("conf_iocapture")
|
||||||
|
|
Loading…
Reference in New Issue