[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='', action="store", dest="keyword", default='',
help="only run test items matching the given (google-style) " help="only run test items matching the given (google-style) "
"keyword expression."), "keyword expression."),
Option('-q', '--start-on', Option('-j', '--keyword-oneshot',
action='store', dest='start_on', default='', action='store_true', dest='keyword_oneshot', default=False,
help="start from first test matching given keyword expression"), help="combined with -k, runs all tests after first hit"),
Option('-l', '--showlocals', Option('-l', '--showlocals',
action="store_true", dest="showlocals", default=False, action="store_true", dest="showlocals", default=False,
help="show locals in tracebacks (disabled by default)."), help="show locals in tracebacks (disabled by default)."),

View File

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

View File

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