[py-svn] commit/pytest: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Mon Sep 17 08:41:38 CEST 2012
2 new commits in pytest:
https://bitbucket.org/hpk42/pytest/changeset/80e95cadda16/
changeset: 80e95cadda16
user: hpk42
date: 2012-09-12 12:51:45
summary: modify detection of factories located in plugins, allowing pytest's own test functions to access plugin defined funcargs even if they use internal machinery instead of a full test run
affected #: 1 file
diff -r a5e7a5fa3c7e8aef9306f60c9e0d42c01e4252c7 -r 80e95cadda16514dbe6934a0f8e4c53fddd0cb2a _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -1235,14 +1235,17 @@
self.session = session
self.config = session.config
self.arg2facspec = {}
- session.config.pluginmanager.register(self, "funcmanage")
+ self._seenplugins = set()
self._holderobjseen = set()
self.setuplist = []
self._arg2finish = {}
+ session.config.pluginmanager.register(self, "funcmanage")
### XXX this hook should be called for historic events like pytest_configure
- ### so that we don't have to do the below pytest_collection hook
+ ### so that we don't have to do the below pytest_configure hook
def pytest_plugin_registered(self, plugin):
+ if plugin in self._seenplugins:
+ return
#print "plugin_registered", plugin
nodeid = ""
try:
@@ -1253,10 +1256,11 @@
if p.basename.startswith("conftest.py"):
nodeid = p.dirpath().relto(self.session.fspath)
self._parsefactories(plugin, nodeid)
+ self._seenplugins.add(plugin)
@pytest.mark.tryfirst
- def pytest_collection(self, session):
- plugins = session.config.pluginmanager.getplugins()
+ def pytest_configure(self, config):
+ plugins = config.pluginmanager.getplugins()
for plugin in plugins:
self.pytest_plugin_registered(plugin)
https://bitbucket.org/hpk42/pytest/changeset/9b4c51b4a2a0/
changeset: 9b4c51b4a2a0
user: hpk42
date: 2012-09-17 08:41:04
summary: merge
affected #: 3 files
diff -r 80e95cadda16514dbe6934a0f8e4c53fddd0cb2a -r 9b4c51b4a2a02e9a3d9a33a1ec35aa3cab942e63 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -56,6 +56,9 @@
- 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
diff -r 80e95cadda16514dbe6934a0f8e4c53fddd0cb2a -r 9b4c51b4a2a02e9a3d9a33a1ec35aa3cab942e63 _pytest/main.py
--- a/_pytest/main.py
+++ b/_pytest/main.py
@@ -114,11 +114,18 @@
def pytest_runtestloop(session):
if session.config.option.collectonly:
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):
- try:
- nextitem = session.items[i+1]
- except IndexError:
- nextitem = None
+ nextitem = getnextitem(i)
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
if session.shouldstop:
raise session.Interrupted(session.shouldstop)
diff -r 80e95cadda16514dbe6934a0f8e4c53fddd0cb2a -r 9b4c51b4a2a02e9a3d9a33a1ec35aa3cab942e63 testing/test_runner.py
--- a/testing/test_runner.py
+++ b/testing/test_runner.py
@@ -180,7 +180,12 @@
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)
""")
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list