[py-svn] r63191 - in py/trunk/py/test: . dsession dsession/testing looponfail plugin testing
hpk at codespeak.net
hpk at codespeak.net
Sat Mar 21 20:28:38 CET 2009
Author: hpk
Date: Sat Mar 21 20:28:35 2009
New Revision: 63191
Modified:
py/trunk/py/test/cmdline.py
py/trunk/py/test/config.py
py/trunk/py/test/dsession/dsession.py
py/trunk/py/test/dsession/testing/test_dsession.py
py/trunk/py/test/looponfail/remote.py
py/trunk/py/test/plugin/pytest_default.py
py/trunk/py/test/session.py
py/trunk/py/test/testing/acceptance_test.py
py/trunk/py/test/testing/test_config.py
Log:
* remove "--exec"
* cleanup of options
Modified: py/trunk/py/test/cmdline.py
==============================================================================
--- py/trunk/py/test/cmdline.py (original)
+++ py/trunk/py/test/cmdline.py Sat Mar 21 20:28:35 2009
@@ -17,7 +17,7 @@
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():
Modified: py/trunk/py/test/config.py
==============================================================================
--- py/trunk/py/test/config.py (original)
+++ py/trunk/py/test/config.py Sat Mar 21 20:28:35 2009
@@ -221,7 +221,9 @@
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 @@
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:
Modified: py/trunk/py/test/dsession/dsession.py
==============================================================================
--- py/trunk/py/test/dsession/dsession.py (original)
+++ py/trunk/py/test/dsession/dsession.py Sat Mar 21 20:28:35 2009
@@ -57,30 +57,14 @@
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
-
- 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
+ super(DSession, self).__init__(config=config)
+
+ 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:
Modified: py/trunk/py/test/dsession/testing/test_dsession.py
==============================================================================
--- py/trunk/py/test/dsession/testing/test_dsession.py (original)
+++ py/trunk/py/test/dsession/testing/test_dsession.py Sat Mar 21 20:28:35 2009
@@ -25,15 +25,6 @@
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)
Modified: py/trunk/py/test/looponfail/remote.py
==============================================================================
--- py/trunk/py/test/looponfail/remote.py (original)
+++ py/trunk/py/test/looponfail/remote.py Sat Mar 21 20:28:35 2009
@@ -49,17 +49,6 @@
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 @@
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 @@
#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()")
Modified: py/trunk/py/test/plugin/pytest_default.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_default.py (original)
+++ py/trunk/py/test/plugin/pytest_default.py Sat Mar 21 20:28:35 2009
@@ -86,7 +86,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
Modified: py/trunk/py/test/session.py
==============================================================================
--- py/trunk/py/test/session.py (original)
+++ py/trunk/py/test/session.py Sat Mar 21 20:28:35 2009
@@ -26,18 +26,6 @@
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:
Modified: py/trunk/py/test/testing/acceptance_test.py
==============================================================================
--- py/trunk/py/test/testing/acceptance_test.py (original)
+++ py/trunk/py/test/testing/acceptance_test.py Sat Mar 21 20:28:35 2009
@@ -14,7 +14,7 @@
result = testdir.runpytest(testdir.tmpdir)
assert result.ret != 0
assert result.stderr.fnmatch_lines([
- 'config ERROR: hello'
+ '*ERROR: hello'
])
def test_basetemp(self, testdir):
Modified: py/trunk/py/test/testing/test_config.py
==============================================================================
--- py/trunk/py/test/testing/test_config.py (original)
+++ py/trunk/py/test/testing/test_config.py Sat Mar 21 20:28:35 2009
@@ -67,22 +67,6 @@
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 @@
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")
More information about the pytest-commit
mailing list