-
Notifications
You must be signed in to change notification settings - Fork 105
[WIP] Extract ExceptionContext from pytest.python_api.RaisesContext. #181
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
Conversation
pytest no longer uses py.code, as such this extraction is unfortunately misplaced i like the idea behind the abstraction tho and would like to figure how to integrate it with the current situation |
I just noticed that this is very similar to |
I created python 33146 to consider adding this functionality to the stdlib (and presumably backported by contextlib2). |
The code begs to differ. |
@jaraco thats |
So if I wanted to extract/present this functionality elsewhere, where would that be? |
Oft Hand thats unclear, pylib is maintenance only and pytest will stop using it long term |
@jaraco perhaps https://github.com/mahmoud/boltons would be a good place for it? Your request seems to me much like a cc @mahmoud |
Thanks for the tip. I'll have to check out boltons. Unfortunately, that only creates yet another home for this functionality, which already has a home at jaraco.context. My main goal with this PR was to consolidate functionality - for pytest to share the functionality from a common source. But it sounds like pytest has no intention of presenting this functionality except in the context of a test runner, so I'll just rely on jaraco.context. |
@jaraco thing is - pylib is in maintenance mode and pytest aims to stop using it altogether - so for pytest to move functonality into pylib is not a path forward |
I occasionally wish I had the interfaces that
pytest.raises
provides without the assertion logic - just the ability to test if an exception occurred and if so retains the details of that exception.This PR extracts that functionality from pytest.
After pytest can depend on this new functionality, its implementation can be pared down to:
This approach provides greater separation of responsibility and allows for greater code re-use by making the ExceptionContext available for broader use (outside of testing frameworks).
This implementation would largely if not wholly obviate jaraco.context.ExceptionTrap. In fact, I wonder if it should be named ExceptionTrap here.
I present this as a work in progress to get your initial reaction and advice on how to proceed. Is the approach attractive and viable? Do you want tests? Documentation? Changelog?