doesn't seem to work with pdb.set_trace()

Issue #647 closed
Former user created an issue

First, I've been a long-time user of - thanks so much for creating it!

I recently have been working on a personal project of mine and uncovered a behavior with 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, but I can't get to properly measure coverage even though I know certain lines of code are being hit in my tests.

It seems to come down to seemingly not playing well with pdb.set_trace(). Here's a very simple script that illustrates the problem I'm having:

import pdb

class FriendlyPdb(pdb.Pdb):

    def cmdloop(self):
        print("Look, a custom pdb!")
        return pdb.Pdb.cmdloop(self)

if __name__ == '__main__':

If I run this Python script, it behaves as you'd expect:

$ coverage run
> /Users/ryanpetrello/<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
------------------------------------------       7      2    71%   6-7

Comments (4)

  1. ryanpetrello

    Apologies for creating this anonymously - I didn't realize Bitbucket allowed that. I'm the person who filed this issue.

  2. Ned Batchelder repo owner

    Both 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 can do anything to make this work.

  3. ryanpetrello


    Thanks for taking the time to reply and confirming I wasn't missing something obvious. Please feel free to close this ticket :).

  4. Log in to comment