-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Testing Flask apps breaks with 5.0.0 #5532
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
Comments
So I tried to tackle this, but my import/module/package/loader knowledge is very limited. The following did allow my Flask tests to pass. class AssertionRewritingHook:
"""PEP302/PEP451 import hook which rewrites asserts."""
def is_package(self, fullname):
raise ImportError and class AssertionRewritingHook:
"""PEP302/PEP451 import hook which rewrites asserts."""
def is_package(self, fullname):
if self._marked_for_rewrite_cache.get(fullname):
return True
raise ImportError I'm not too sure what the proper thing to do here is. The first one works and The second one is probably more in line with what the API requires, but it's a shot in the dark for me. I really need a proper pytest adult here :) Cheers |
Oh and it looks like it's a regression from #5468 |
flask is sadly incorrect here, I believe the replacement is to check let's see if I can't fix it from the flask side |
Handling this in flask: pallets/flask#3275 |
Thanks @asottile! Should we implement If it is a two liner, I think it is worth it to avoid the small pain this can cause, even though it is not pytest's fault. |
It is very difficult to implement correctly I'm afraid (since it gets queried before the module spec inference has run) -- this was the gnarly recursive somewhat-broken code I had before I switched to the PEP 451 loader approach |
I see, thanks! |
closing since we fixed this up(down? I can never remember which direction is right)stream -- thanks again for the report @aberres and @RemiCardona 🎉 ! |
If this affects all flask users, perhaps a tweet commenting on this issue would be good? |
it shouldn't affect all (or even many I would think?) flask users, only those which define flask apps inside of a test module (for instance, my tested flask things all appear to be fine 🤷♂) |
Ahh OK, thanks! |
The latest version of flask (released yesterday) contains the fix (1.0.4 / 1.1.0) |
Bump Flask due to pytest-dev/pytest#5532
Uh oh!
There was an error while loading. Please reload this page.
I just upgraded to 5.0.0 and even the most simplistic Flask app cannot be tested anymore.
It seems as if this might be related to an issue from 2013: #317
Minimalistic test case
Backtrace
The text was updated successfully, but these errors were encountered: