diff --git a/py/test/defaultconftest.py b/py/test/defaultconftest.py index 24bb5da2b..917b2ea7b 100644 --- a/py/test/defaultconftest.py +++ b/py/test/defaultconftest.py @@ -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)."), diff --git a/py/test/session.py b/py/test/session.py index 5673816d1..acbbd7f5a 100644 --- a/py/test/session.py +++ b/py/test/session.py @@ -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() diff --git a/py/test/testing/test_session.py b/py/test/testing/test_session.py index 2238d2f7a..cd584c5c6 100644 --- a/py/test/testing/test_session.py +++ b/py/test/testing/test_session.py @@ -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)