From a94a6b42822ed660361ec8bd0ca01d98ae565ba9 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 10 Dec 2011 08:49:21 +0000 Subject: [PATCH] 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 --- CHANGELOG | 5 +++++ _pytest/__init__.py | 2 +- _pytest/resultlog.py | 5 ++++- setup.py | 6 +++--- testing/test_resultlog.py | 11 +++++++---- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 075b693d8..c9bd738d9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ 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": 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 diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 767fe51ef..23b8395b9 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.2.1.dev2' +__version__ = '2.2.1.dev3' diff --git a/_pytest/resultlog.py b/_pytest/resultlog.py index 02abe7659..94ac67a7d 100644 --- a/_pytest/resultlog.py +++ b/_pytest/resultlog.py @@ -91,5 +91,8 @@ class ResultLog(object): self.log_outcome(report, code, longrepr) 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)) diff --git a/setup.py b/setup.py index d0be8894b..6fb1c4873 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.2.1.dev2', + version='2.2.1.dev3', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], @@ -32,7 +32,7 @@ def main(): author_email='holger at merlinux.eu', entry_points= make_entry_points(), # 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', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', @@ -70,4 +70,4 @@ def make_entry_points(): return {'console_scripts': l} if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/testing/test_resultlog.py b/testing/test_resultlog.py index 476a76b54..9a3bb6465 100644 --- a/testing/test_resultlog.py +++ b/testing/test_resultlog.py @@ -133,23 +133,26 @@ class TestWithFunctionIntegration: assert lines[14].startswith('X ') 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 - # at the end of the run + # at the end of the run or a failing hook invocation try: raise ValueError except ValueError: excinfo = py.code.ExceptionInfo() reslog = ResultLog(None, py.io.TextIO()) - reslog.pytest_internalerror(excinfo.getrepr()) + reslog.pytest_internalerror(excinfo.getrepr(style=style)) entry = reslog.logfile.getvalue() entry_lines = entry.splitlines() assert entry_lines[0].startswith('! ') - assert os.path.basename(__file__)[:-9] in entry_lines[0] #.pyc/class + if style != "native": + assert os.path.basename(__file__)[:-9] in entry_lines[0] #.pyc/class assert entry_lines[-1][0] == ' ' assert 'ValueError' in entry + def test_generic(testdir, LineMatcher): testdir.plugins.append("resultlog") testdir.makepyfile("""