You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, I've been a long-time user of coverage.py - thanks so much for creating it!
I recently have been working on a personal project of mine and uncovered a behavior with coverage.py that has me stumped.
Without going into too many gory details, my project is an extension to Python's pdb debugger that allows you to debug non-interactive Python programs over a telnet session. I've written some tests for it and am attempting to use coverage.py, but I can't get coverage.py to properly measure coverage even though I know certain lines of code are being hit in my tests.
It seems to come down to coverage.py seemingly not playing well with pdb.set_trace(). Here's a very simple script that illustrates the problem I'm having:
#!python
import pdb
class FriendlyPdb(pdb.Pdb):
def cmdloop(self):
print("Look, a custom pdb!")
return pdb.Pdb.cmdloop(self)
if __name__ == '__main__':
FriendlyPdb().set_trace()
If I run this Python script, it behaves as you'd expect:
$ coverage run example.py
--Return--
> /Users/ryanpetrello/example.py(11)<module>()->None
-> FriendlyPdb().set_trace()
Look, a custom pdb!
(Pdb) c
Yet the coverage report says that lines 6-7 (the contents of the cmdloop function) are missing:
$ coverage report -m
Name Stmts Miss Cover Missing
------------------------------------------
example.py 7 2 71% 6-7
Both coverage.py and debuggers use the trace function feature. If everyone was careful to chain the trace functions, it might work, but I don't think pdb invokes a previous trace function in its function. I'm not sure coverage.py can do anything to make this work.
Originally reported by Anonymous
First, I've been a long-time user of coverage.py - thanks so much for creating it!
I recently have been working on a personal project of mine and uncovered a behavior with coverage.py that has me stumped.
Without going into too many gory details, my project is an extension to Python's pdb debugger that allows you to debug non-interactive Python programs over a telnet session. I've written some tests for it and am attempting to use coverage.py, but I can't get coverage.py to properly measure coverage even though I know certain lines of code are being hit in my tests.
It seems to come down to coverage.py seemingly not playing well with
pdb.set_trace()
. Here's a very simple script that illustrates the problem I'm having:If I run this Python script, it behaves as you'd expect:
Yet the coverage report says that lines 6-7 (the contents of the cmdloop function) are missing:
The text was updated successfully, but these errors were encountered: