Merge pull request #1614 from gnprice/loop
Simplify default pytest_runtestloop
This commit is contained in:
commit
c5424643f0
1
AUTHORS
1
AUTHORS
|
@ -47,6 +47,7 @@ Floris Bruynooghe
|
||||||
Gabriel Reis
|
Gabriel Reis
|
||||||
Georgy Dyuldin
|
Georgy Dyuldin
|
||||||
Graham Horler
|
Graham Horler
|
||||||
|
Greg Price
|
||||||
Grig Gheorghiu
|
Grig Gheorghiu
|
||||||
Guido Wesdorp
|
Guido Wesdorp
|
||||||
Harald Armin Massa
|
Harald Armin Massa
|
||||||
|
|
|
@ -136,17 +136,8 @@ def pytest_runtestloop(session):
|
||||||
if session.config.option.collectonly:
|
if session.config.option.collectonly:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getnextitem(i):
|
|
||||||
# this is a function to avoid python2
|
|
||||||
# keeping sys.exc_info set when calling into a test
|
|
||||||
# python2 keeps sys.exc_info till the frame is left
|
|
||||||
try:
|
|
||||||
return session.items[i+1]
|
|
||||||
except IndexError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
for i, item in enumerate(session.items):
|
for i, item in enumerate(session.items):
|
||||||
nextitem = getnextitem(i)
|
nextitem = session.items[i+1] if i+1 < len(session.items) else None
|
||||||
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
|
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
|
||||||
if session.shouldstop:
|
if session.shouldstop:
|
||||||
raise session.Interrupted(session.shouldstop)
|
raise session.Interrupted(session.shouldstop)
|
||||||
|
|
Loading…
Reference in New Issue