[svn r41855] Add a bit hackish option which allows to start from selected
keyword test, doesn't work with rsession yet. --HG-- branch : trunk
This commit is contained in:
parent
1e7bb8ca99
commit
d8e5e63235
|
@ -43,6 +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('-l', '--showlocals',
|
||||
action="store_true", dest="showlocals", default=False,
|
||||
help="show locals in tracebacks (disabled by default)."),
|
||||
|
|
|
@ -9,6 +9,12 @@ 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
|
||||
|
||||
def shouldclose(self):
|
||||
return False
|
||||
|
@ -39,6 +45,9 @@ 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"
|
||||
|
||||
def start(self, colitem):
|
||||
""" hook invoked before each colitem.run() invocation. """
|
||||
|
||||
|
@ -102,7 +111,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.config.option.keyword)
|
||||
colitem._skipbykeyword(self.keyword)
|
||||
if self.config.option.start_on:
|
||||
self.keyword = ""
|
||||
res = colitem.run()
|
||||
if res is None:
|
||||
return Passed()
|
||||
|
|
|
@ -81,6 +81,16 @@ namecontent = [
|
|||
assert 42 == 43
|
||||
|
||||
''')),
|
||||
('testmore.py', py.code.Source('''
|
||||
def test_one():
|
||||
assert 1
|
||||
|
||||
def test_two():
|
||||
assert 1
|
||||
|
||||
def test_three():
|
||||
assert 1
|
||||
''')),
|
||||
|
||||
('testspecial_importerror.py', py.code.Source('''
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ implied_options = {
|
|||
conflict_options = ('--looponfailing --pdb',
|
||||
'--dist --pdb',
|
||||
'--exec=%s --pdb' % py.std.sys.executable,
|
||||
'-k xxx -q xxx',
|
||||
)
|
||||
|
||||
def test_conflict_options():
|
||||
|
@ -97,6 +98,17 @@ class TestKeywordSelection:
|
|||
l = session.getitemoutcomepairs(Skipped)
|
||||
assert l[0][0].name == 'test_1'
|
||||
|
||||
def test_select_starton(self):
|
||||
config = py.test.config._reparse([datadir/'testmore.py',
|
||||
'-q', "test_two"])
|
||||
session = config._getsessionclass()(config, py.std.sys.stdout)
|
||||
session.main()
|
||||
l = session.getitemoutcomepairs(Passed)
|
||||
assert len(l) == 2
|
||||
l = session.getitemoutcomepairs(Skipped)
|
||||
assert len(l) == 1
|
||||
|
||||
|
||||
class TestTerminalSession:
|
||||
def mainsession(self, *args):
|
||||
from py.__.test.terminal.terminal import TerminalSession
|
||||
|
|
Loading…
Reference in New Issue