fix issue 188 - ensure sys.exc_info on py2 is clear before calling into a test
This commit is contained in:
parent
bfaf8e50b6
commit
bf5b226474
|
@ -56,6 +56,9 @@ Changes between 2.2.4 and 2.3.0.dev
|
|||
|
||||
- fix issue 182: testdir.inprocess_run now considers passed plugins
|
||||
|
||||
- fix issue 188: ensure sys.exc_info is clear on python2
|
||||
before calling into a test
|
||||
|
||||
- reporting refinements:
|
||||
|
||||
- pytest_report_header now receives a "startdir" so that
|
||||
|
|
|
@ -114,11 +114,18 @@ def pytest_collection(session):
|
|||
def pytest_runtestloop(session):
|
||||
if session.config.option.collectonly:
|
||||
return True
|
||||
for i, item in enumerate(session.items):
|
||||
|
||||
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:
|
||||
nextitem = session.items[i+1]
|
||||
return session.items[i+1]
|
||||
except IndexError:
|
||||
nextitem = None
|
||||
return None
|
||||
|
||||
for i, item in enumerate(session.items):
|
||||
nextitem = getnextitem(i)
|
||||
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
|
||||
if session.shouldstop:
|
||||
raise session.Interrupted(session.shouldstop)
|
||||
|
|
|
@ -180,7 +180,12 @@ class BaseFunctionalTests:
|
|||
raise Exception()
|
||||
|
||||
def test_func():
|
||||
pass
|
||||
import sys
|
||||
# on python2 exc_info is keept till a function exits
|
||||
# so we would end up calling test functions while
|
||||
# sys.exc_info would return the indexerror
|
||||
# from guessing the lastitem
|
||||
assert sys.exc_info()[0] is None
|
||||
def teardown_function(func):
|
||||
raise ValueError(42)
|
||||
""")
|
||||
|
|
Loading…
Reference in New Issue