-
Notifications
You must be signed in to change notification settings - Fork 111
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
if some fail in teardown could be trigger _post_teardown error #21
Comments
Could we add some fault-tolerance to the _post_teardown and else flask-testing methods to raise the real errors ? |
@jarus can you please take a look at this? I've also got this problem |
Setting |
+1 to @eriktaubeneck , fixed my py.test, thanks! |
@eriktaubeneck 💯 worked... :) |
+1 this is still failing even with PRESERVE_CONTEXT_ON_EXCEPTION = False |
api.v1.update_unit and api.v1.show_unit now check to ensure the user logged in is the user who created the resources. Changed nightshades.api.get_unit to accept the user_id as a keyword argument. This way the method is still useful when no user check is deliberately needed, but it is still available. nightshades.api.mark_complete is now handled in the same way. The api.v1 Blueprint now has an error handler for peewee.DoesNotExist exceptions so it will throw a JSON API 404. Which exceptions the internal API can possibly throw should be reviewed and this exception handling should be organized. I think that having the route actions raise exceptions (instead of `abort`ing) followed by Flask errorhandler decorators makes more sense. PRESERVE_CONTEXT_ON_EXCEPTION config flag in the test client is due to: jarus/flask-testing#21
PRESERVE_CONTEXT_ON_EXCEPTION = False, is not working for me |
This is necessary since in some situations, flask raises two exceptions which confuses the request context. See http://stackoverflow.com/a/28139033/2443886 and jarus/flask-testing#21
I found what was causing the error in my case, the error handler itself had an error (which hasn't been raised). |
I used flask-testing years ago. This feature doesn't need anymore. |
This is still an issue in the latest version of flask-testing (v0.6.2). Setting |
Just to add some clarity, the This is because, from the flask config docs (http://flask.pocoo.org/docs/0.12/config/)...
So the other way to avoid this issue is to turn the debug flag off for testing:
|
I started to receive the same errors too and none of the above suggestions has helped, not the What did help in my case is turning off shared fixtures ( This way my test runs became a bit less efficient, but now at least they don't error out randomly with the above error. |
I'm still facing this issue when I try to test background tasks using python-rq and have come across the same issue of I'm on python3.8 and using flask 2.0 P.S setting fixture scope to default also doesn't help the case
|
This is the only thing that worked for me. Looking for the efficient way by preserving the session scope... |
I custome my TestCase's teardown method, and it case a error.
When I run this case, it could raise a error about Flask-testing's
self._ctx.pop()
error (link) .That make me can't find real problem except I note r85 .
When the teardown method raise a error, flask-testing execute the _post_teardown will case this error :
The text was updated successfully, but these errors were encountered: