-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Code executed by exec excluded from coverage #380
Comments
Looks like exec'ing code gets the called code and the calling code confused in the frame. I've added a warning when this happens here: b981d945481a (bb). There's probably a way to get this right, still working on it. |
If file disagrees with the frame, use the frame info. Fixes #380. → <<cset 2372daa1d74b (bb)>> |
Required for coverage.py since it uses the same filename. Ref: nedbat/coveragepy#380 Code: https://github.com/nedbat/coveragepy/blob/1c06204a8b1db6cd5f53c553c42f3ef8229d6b20/coverage/inorout.py#L222-L231
I've just came across this, and wanted to note that it does not work when the exec'd (base) filename is the same, as with pdbpp's hack: pdbpp/pdbpp@f67ad89 |
Another note: I had code like |
How can I include code executed with exec ? |
Originally reported by mb2297 (Bitbucket: mb2297, GitHub: Unknown)
It might be unrealistic to expect this to work, but python files that are read and then executed with exec (or with execfile) aren't counted towards the coverage report.
Example:
Results in the following on both OS X and Ubuntu:
The example is also at https://gist.github.com/mattbennett/f57a5286bd77ee52651e if you want to clone and verify.
The text was updated successfully, but these errors were encountered: