Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pytestbot opened this issue Apr 7, 2011 · 2 comments
Closed

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

pytestbot opened this issue Apr 7, 2011 · 2 comments
Labels
type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

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

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue38 - nicer tracebacks on sessionstart/configure (and other internal/custom hook failures)

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


you can try out the fix with "pip install -U pytest -i http://pypi.testrun.org" - traceback will be "native" and it's also possible to specify "--fulltrace" in order to get a full traceback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

1 participant