Skip to content

Traceback with --pdb refers to previous pdb.set_trace() #3237

Closed
@blueyed

Description

@blueyed

Given t/test_pdb_offset.py:

def raises():
    raise Exception('outer')


def test_pdb_offset():
    __import__('pdb').set_trace()
    print(1)

    raises()

Running pytest t/test_pdb_offset.py --tb=short --pdb result in:

==================================== test session starts ====================================
platform linux -- Python 3.6.4, pytest-3.4.1.dev51+gb486e129, py-1.5.2, pluggy-0.6.0
rootdir: …/Vcs/pytest, inifile: tox.ini
collected 1 item                                                                            

t/test_pdb_offset.py 
>>>>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>>>>>>>
> …/Vcs/pytest/t/test_pdb_offset.py(7)test_pdb_offset()
-> print(1)
(Pdb) c
1
F
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
t/test_pdb_offset.py:7: in test_pdb_offset
    print(1)
t/test_pdb_offset.py:2: in raises
    raise Exception('outer')
E   Exception: outer
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> …/Vcs/pytest/t/test_pdb_offset.py(2)raises()
-> raise Exception('outer')
(Pdb) c
                                                                                      [100%]
================================== short test summary info ==================================
FAIL t/test_pdb_offset.py::test_pdb_offset

Notice the first entry in the traceback (t/test_pdb_offset.py:7), which refers to the line after the pdb.set_trace(), but it should be the line where raises gets called.

pytest 3.4.1.dev51+gb486e129.

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: debuggingrelated to the debugging builtin plugintype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions