Skip to content

Add a pytest option to not reinterpret exceptions in hooks #38

Closed
@pytestbot

Description

@pytestbot

Originally reported by: Vyacheslav Rafalskiy (BitBucket: s4g, GitHub: s4g)


In some use cases, especially in functional testing, the pytest_configure(), pytest_sessionstart() and other hooks can be loaded with heavy setup code, which can fail in many different ways. If exceptions in such code are reinterpreted, as is the case in pytest 2.0.2, the important pre-formatted messages and traces are lost, or at least disfigured by long listings with every line prepended with 'INTERNALERROR>'.

It is desirable to be able to avoid such reinterpretation with a command-line option or other means.

Presently, I use the following monkey-patch as a workaround:

#!python

import sys, _pytest.core

def _notify_exception(self, excinfo):
    excrepr = excinfo.getrepr(style='native')
    sys.stderr.write(excrepr)

_pytest.core.PluginManager.notify_exception = _notify_exception

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions