Skip to content

Drop into debugger at the first line of a test. #3610

@guocb

Description

@guocb

Thanks for the work of pytest which is a great tool.

This actually a feature request. I know we could use --pdb to stop the test running and drop into a debugger. But for some cases, it's too late, e.g.

def test_foo():
    result = foo()
    self.assertEqual(result, 0)

In this case, we have no chance to re-run foo and get to know what happened. We have to manually add a breakpoint at the first line of test_foo(), run the test again, fix the problem, and finally remove the breakpoint.

My suggestion is to add an option, say --trace which can automatically drop into debugger for at the first line of selected tests, that will boost the cycle of trouble shooting when combine with either option --lf or -k.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wanteddevelopers would like help from experts on this topictype: enhancementnew feature or API change, should be merged into features branchtype: feature-branchnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions