[py-svn] commit/pytest: hpk42: fix issue49 - avoid confusing errors when initialization goes wrong
Bitbucket
commits-noreply at bitbucket.org
Wed Jun 1 14:55:17 CEST 2011
1 new changeset in pytest:
http://bitbucket.org/hpk42/pytest/changeset/502331edf550/
changeset: 502331edf550
branches:
user: hpk42
date: 2011-06-01 14:54:34
summary: fix issue49 - avoid confusing errors when initialization goes wrong
affected #: 2 files (543 bytes)
--- a/_pytest/main.py Wed Jun 01 08:03:06 2011 +0200
+++ b/_pytest/main.py Wed Jun 01 14:54:34 2011 +0200
@@ -58,9 +58,12 @@
"""Skeleton command line program"""
session = Session(config)
session.exitstatus = EXIT_OK
+ initstate = 0
try:
config.pluginmanager.do_configure(config)
+ initstate = 1
config.hook.pytest_sessionstart(session=session)
+ initstate = 2
doit(config, session)
except pytest.UsageError:
raise
@@ -76,9 +79,11 @@
sys.stderr.write("mainloop: caught Spurious SystemExit!\n")
if not session.exitstatus and session._testsfailed:
session.exitstatus = EXIT_TESTSFAILED
- config.hook.pytest_sessionfinish(session=session,
- exitstatus=session.exitstatus)
- config.pluginmanager.do_unconfigure(config)
+ if initstate >= 2:
+ config.hook.pytest_sessionfinish(session=session,
+ exitstatus=session.exitstatus)
+ if initstate >= 1:
+ config.pluginmanager.do_unconfigure(config)
return session.exitstatus
def pytest_cmdline_main(config):
--- a/testing/acceptance_test.py Wed Jun 01 08:03:06 2011 +0200
+++ b/testing/acceptance_test.py Wed Jun 01 14:54:34 2011 +0200
@@ -259,6 +259,19 @@
if name.startswith("pytest_"):
assert value.__doc__, "no docstring for %s" % name
+ def test_initialization_error_issue49(self, testdir):
+ testdir.makeconftest("""
+ def pytest_configure():
+ x
+ """)
+ result = testdir.runpytest()
+ assert result.ret == 3 # internal error
+ result.stderr.fnmatch_lines([
+ "INTERNAL*pytest_configure*",
+ "INTERNAL*x*",
+ ])
+ assert 'sessionstarttime' not in result.stderr.str()
+
class TestInvocationVariants:
def test_earlyinit(self, testdir):
p = testdir.makepyfile("""
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