[svn r41860] * kill start_on

* add keyword_oneshot flag, which indicates that -k is only one shot
  than all tests are run
* simplify code a bit

--HG--
branch : trunk
This commit is contained in:
fijal 2007-04-03 19:28:04 +02:00
parent d8e5e63235
commit 50d77c64c0
3 changed files with 10 additions and 16 deletions

View File

@ -43,9 +43,9 @@ def adddefaultoptions(config):
action="store", dest="keyword", default='',
help="only run test items matching the given (google-style) "
"keyword expression."),
Option('-q', '--start-on',
action='store', dest='start_on', default='',
help="start from first test matching given keyword expression"),
Option('-j', '--keyword-oneshot',
action='store_true', dest='keyword_oneshot', default=False,
help="combined with -k, runs all tests after first hit"),
Option('-l', '--showlocals',
action="store_true", dest="showlocals", default=False,
help="show locals in tracebacks (disabled by default)."),

View File

@ -9,12 +9,7 @@ class Session(object):
def __init__(self, config):
self._memo = []
self.config = config
if config.option.start_on:
self.keyword = config.option.start_on
elif config.option.keyword:
self.keyword = config.option.keyword
else:
self.keyword = None
self._keyword = config.option.keyword
def shouldclose(self):
return False
@ -45,8 +40,8 @@ class Session(object):
if option.executable and option.usepdb:
raise ValueError, "--exec together with --pdb not supported."
if option.keyword and option.start_on:
raise ValueError, "--start-on and --keyword not supported"
if option.keyword_oneshot and not option.keyword:
raise ValueError, "--keyword-oneshot makes sense only when --keyword is supplied"
def start(self, colitem):
""" hook invoked before each colitem.run() invocation. """
@ -111,9 +106,9 @@ class Session(object):
if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item):
return
if isinstance(colitem, py.test.collect.Item):
colitem._skipbykeyword(self.keyword)
if self.config.option.start_on:
self.keyword = ""
colitem._skipbykeyword(self._keyword)
if self.config.option.keyword_oneshot:
self._keyword = ""
res = colitem.run()
if res is None:
return Passed()

View File

@ -12,7 +12,6 @@ implied_options = {
conflict_options = ('--looponfailing --pdb',
'--dist --pdb',
'--exec=%s --pdb' % py.std.sys.executable,
'-k xxx -q xxx',
)
def test_conflict_options():
@ -100,7 +99,7 @@ class TestKeywordSelection:
def test_select_starton(self):
config = py.test.config._reparse([datadir/'testmore.py',
'-q', "test_two"])
'-j', '-k', "test_two"])
session = config._getsessionclass()(config, py.std.sys.stdout)
session.main()
l = session.getitemoutcomepairs(Passed)