Skip to content

Commit c542464

Browse files
authored
Merge pull request #1614 from gnprice/loop
Simplify default pytest_runtestloop
2 parents 66e66f6 + ab8b2e7 commit c542464

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Floris Bruynooghe
4747
Gabriel Reis
4848
Georgy Dyuldin
4949
Graham Horler
50+
Greg Price
5051
Grig Gheorghiu
5152
Guido Wesdorp
5253
Harald Armin Massa

_pytest/main.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,8 @@ def pytest_runtestloop(session):
136136
if session.config.option.collectonly:
137137
return True
138138

139-
def getnextitem(i):
140-
# this is a function to avoid python2
141-
# keeping sys.exc_info set when calling into a test
142-
# python2 keeps sys.exc_info till the frame is left
143-
try:
144-
return session.items[i+1]
145-
except IndexError:
146-
return None
147-
148139
for i, item in enumerate(session.items):
149-
nextitem = getnextitem(i)
140+
nextitem = session.items[i+1] if i+1 < len(session.items) else None
150141
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
151142
if session.shouldstop:
152143
raise session.Interrupted(session.shouldstop)

0 commit comments

Comments
 (0)