Skip to content
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

Coverage with/after pdb.set_trace #729

Open
blueyed opened this issue Nov 11, 2018 · 1 comment
Open

Coverage with/after pdb.set_trace #729

blueyed opened this issue Nov 11, 2018 · 1 comment
Labels
exotic Unusual execution environment

Comments

@blueyed
Copy link
Contributor

blueyed commented Nov 11, 2018

Given t-coverage.py:

import sys


print(1)

trace = sys.gettrace()

__import__('pdb').set_trace()

sys.settrace(trace)

print(2)
print(3)

Running coverage run t-coverage.py && coverage report -m t-coverage.py results in:

1
> /home/daniel/Vcs/coveragepy/t-coverage.py(10)<module>()
-> sys.settrace(trace)
(Pdb) c
2
3
Name            Stmts   Miss  Cover   Missing
---------------------------------------------
t-coverage.py       7      3    57%   10-13

coverage annotate shows that the pdb.set_trace() and the code after it is not covered:

! sys.settrace(trace)
  
! print(2)
! print(3)

I have seen #647, but the issue there appears to be different.
It was mentioned there that it might work if chained correctly, which I've tried to achieve by (re)storing the previous trace function: #647 (comment)

Is this what was meant, or would the wrapping/chaining need to happen in another way?

Python 3.7.1
Coverage.py, version 4.5.1 with C extension

@blueyed
Copy link
Contributor Author

blueyed commented Mar 22, 2019

I think it would be good for pdb itself to set a function on sys.settrace, which would call the original function (i.e. coverage.py's) after its own processing, and not set it to None in the end, but restore the previous one.

@nedbat nedbat added the exotic Unusual execution environment label Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exotic Unusual execution environment
Projects
None yet
Development

No branches or pull requests

2 participants