fix issue99 - internalerror with --resultlog now produce better output.

the fix depends on another change in the py lib which unifies
the output for native and non-native traceback formatting styles
This commit is contained in:
holger krekel 2011-12-10 08:49:21 +00:00
parent af0edf0d10
commit a94a6b4282
5 changed files with 20 additions and 9 deletions

View File

@ -1,6 +1,11 @@
Changes between 2.2.0 and 2.2.1.dev Changes between 2.2.0 and 2.2.1.dev
---------------------------------------- ----------------------------------------
- fix issue99 (in pytest and py) internallerrors with resultlog now
produce better output - fixed by normalizing pytest_internalerror
input arguments.
- fix traceback issues (in pytest and py) improve traceback output
in conjunction with jinja2 and cython which hack tracebacks
- fix issue93 (in pytest and pytest-xdist) avoid "delayed teardowns": - fix issue93 (in pytest and pytest-xdist) avoid "delayed teardowns":
the final test in a test node will now run its teardown directly the final test in a test node will now run its teardown directly
instead of waiting for the end of the session. Thanks Dave Hunt for instead of waiting for the end of the session. Thanks Dave Hunt for

View File

@ -1,2 +1,2 @@
# #
__version__ = '2.2.1.dev2' __version__ = '2.2.1.dev3'

View File

@ -91,5 +91,8 @@ class ResultLog(object):
self.log_outcome(report, code, longrepr) self.log_outcome(report, code, longrepr)
def pytest_internalerror(self, excrepr): def pytest_internalerror(self, excrepr):
path = excrepr.reprcrash.path reprcrash = getattr(excrepr, 'reprcrash', None)
path = getattr(reprcrash, "path", None)
if path is None:
path = "cwd:%s" % py.path.local()
self.write_log_entry(path, '!', str(excrepr)) self.write_log_entry(path, '!', str(excrepr))

View File

@ -24,7 +24,7 @@ def main():
name='pytest', name='pytest',
description='py.test: simple powerful testing with Python', description='py.test: simple powerful testing with Python',
long_description = long_description, long_description = long_description,
version='2.2.1.dev2', version='2.2.1.dev3',
url='http://pytest.org', url='http://pytest.org',
license='MIT license', license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
@ -32,7 +32,7 @@ def main():
author_email='holger at merlinux.eu', author_email='holger at merlinux.eu',
entry_points= make_entry_points(), entry_points= make_entry_points(),
# the following should be enabled for release # the following should be enabled for release
install_requires=['py>=1.4.5'], install_requires=['py>=1.4.6.dev4'],
classifiers=['Development Status :: 6 - Mature', classifiers=['Development Status :: 6 - Mature',
'Intended Audience :: Developers', 'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License', 'License :: OSI Approved :: MIT License',

View File

@ -133,23 +133,26 @@ class TestWithFunctionIntegration:
assert lines[14].startswith('X ') assert lines[14].startswith('X ')
assert len(lines) == 15 assert len(lines) == 15
def test_internal_exception(self): @pytest.mark.parametrize("style", ("native", "long", "short"))
def test_internal_exception(self, style):
# they are produced for example by a teardown failing # they are produced for example by a teardown failing
# at the end of the run # at the end of the run or a failing hook invocation
try: try:
raise ValueError raise ValueError
except ValueError: except ValueError:
excinfo = py.code.ExceptionInfo() excinfo = py.code.ExceptionInfo()
reslog = ResultLog(None, py.io.TextIO()) reslog = ResultLog(None, py.io.TextIO())
reslog.pytest_internalerror(excinfo.getrepr()) reslog.pytest_internalerror(excinfo.getrepr(style=style))
entry = reslog.logfile.getvalue() entry = reslog.logfile.getvalue()
entry_lines = entry.splitlines() entry_lines = entry.splitlines()
assert entry_lines[0].startswith('! ') assert entry_lines[0].startswith('! ')
if style != "native":
assert os.path.basename(__file__)[:-9] in entry_lines[0] #.pyc/class assert os.path.basename(__file__)[:-9] in entry_lines[0] #.pyc/class
assert entry_lines[-1][0] == ' ' assert entry_lines[-1][0] == ' '
assert 'ValueError' in entry assert 'ValueError' in entry
def test_generic(testdir, LineMatcher): def test_generic(testdir, LineMatcher):
testdir.plugins.append("resultlog") testdir.plugins.append("resultlog")
testdir.makepyfile(""" testdir.makepyfile("""