-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Assert rewrite causes reload() to fail #743
Comments
Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub): Right, I looked at the code and while it disables rewriting of the assertions it still generates the py.test specific bytecode file. So you'd still not have reload work. Not yet sure what would be required to support reload properly. Btw, looking at your script you probably don't really have to have this problem. You do realise you can replace a lot of the code in the example with the tmpdir fixture (http://pytest.org/latest/tmpdir.html). It would get rid of the temporary directory creation and atexit stuff quite easily. You might even be able to work around the reload things using the |
Original comment by BitBucket: lcampagn, GitHub: lcampagn: Thanks, the I wonder if it would be possible for the module rewriter to check for calls to reload() in addition to assertions, and insert a function call that would check for bytecode files that need to be rebuilt. |
do we have any more feedback on this, do we even want to try and support it? |
Nice, thanks for the ping, didn't know about For cross-reference: #2203. I think it should be simple to make Hmm it might hard to get more feedback on this from the OP, as there's no Given that I think we can close this issue and continue the discussion over #2203 then. |
OP here; I am still looking for a solution. Happy to provide feedback or test ideas! |
@campagnola one thing i dont understand is why reload was needed, the other bit is i wonder how reload interacts with the module loading peps |
I just found a workaround which, in retrospect, is obvious: assertion rewriting is only done on files that are named like test modules, so all I had to do was pick a different name for the temporary module and it will be ignored by the rewriter. |
Originally reported by: BitBucket: lcampagn, GitHub: lcampagn
I have a unit test that passes when run with assert=plain or reinterp, but fails with rewrite. I also looked over #435, but I believe this is a separate issue. The offending test is attached. It works by writing a module to be imported, then re-writing, reloading it, and testing that the reload worked as expected.
I imagine there might be no sane way to fix this bug. If that is the case, then is there a way to disable assertion rewriting on a per-module basis? I was a bit surprised to find that adding messages to the assert statements did not fix the problem.
The text was updated successfully, but these errors were encountered: