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

Setting a breakpoint before failure invokes pdb #314

Open
mrsmond opened this issue Nov 2, 2016 · 0 comments
Open

Setting a breakpoint before failure invokes pdb #314

mrsmond opened this issue Nov 2, 2016 · 0 comments

Comments

@mrsmond
Copy link

mrsmond commented Nov 2, 2016

Hi,

When I run nose2 -D, it will cause pdb to be started when a test fails, which is on a line that has a call to "self.assertTrue" or other, however, the bit of code that I want to debug - by setting a breakpoint on it - is called earlier. I've tried setting the breakpoint and then issuing the pdb command run/restart, but I get the following error:

FAILED (failures=1)
ERROR:nose2.main:Internal Error
Traceback (most recent call last):
  File "/home/mond/.local/lib/python3.5/site-packages/nose2/main.py", line 271, in runTests
    self.result = runner.run(self.test)
  File "/home/mond/.local/lib/python3.5/site-packages/nose2/runner.py", line 53, in run
    executor(test, result)
  File "/home/mond/.local/lib/python3.5/site-packages/nose2/runner.py", line 41, in <lambda>
    executor = lambda suite, result: suite(result)
  File "/usr/lib/python3.5/unittest/suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python3.5/unittest/suite.py", line 122, in run
    test(result)
  File "/usr/lib/python3.5/unittest/suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python3.5/unittest/suite.py", line 122, in run
    test(result)
  File "/usr/lib/python3.5/unittest/suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python3.5/unittest/suite.py", line 122, in run
    test(result)
  File "/usr/lib/python3.5/unittest/case.py", line 648, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python3.5/unittest/case.py", line 608, in run
    self._feedErrorsToResult(result, outcome.errors)
  File "/usr/lib/python3.5/unittest/case.py", line 536, in _feedErrorsToResult
    result.addFailure(test, exc_info)
  File "/home/mond/.local/lib/python3.5/site-packages/nose2/result.py", line 69, in addFailure
    self.session.hooks.testOutcome(event)
  File "/home/mond/.local/lib/python3.5/site-packages/nose2/events.py", line 224, in __call__
    result = getattr(plugin, self.method)(event)
  File "/home/mond/.local/lib/python3.5/site-packages/nose2/plugins/debugger.py", line 58, in testOutcome
    self.pdb.post_mortem(tb)
  File "/usr/lib/python3.5/pdb.py", line 1595, in post_mortem
    p.interaction(None, t)
  File "/usr/lib/python3.5/pdb.py", line 346, in interaction
    self._cmdloop()
  File "/usr/lib/python3.5/pdb.py", line 319, in _cmdloop
    self.cmdloop()
  File "/usr/lib/python3.5/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python3.5/pdb.py", line 412, in onecmd
    return cmd.Cmd.onecmd(self, line)
  File "/usr/lib/python3.5/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/lib/python3.5/pdb.py", line 1022, in do_run
    raise Restart
pdb.Restart
Internal Error: runTests aborted: 

How can I set a breakpoint and re-run? I could run the test file in pdb, create the testcase class, etc but I wondered if there was an easier way.

Using the pdb command jump doesn't work because it can only jump around in the bottom stack frame, which is inside nose not my code.

And using a .pdbrc to set the breakpoint doesn't work either. The text that says a breakpoint has been set is printed out but it still invokes pdb on the assertion failure and not the earlier code which has the breakpoint on it.

Many thanks,

Derek

@katrinabrock katrinabrock self-assigned this Jul 12, 2017
@katrinabrock katrinabrock removed their assignment Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants