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

Error when adding ipdb.set_trace() inside tests #274

Closed
montaro opened this issue Oct 5, 2016 · 4 comments
Closed

Error when adding ipdb.set_trace() inside tests #274

montaro opened this issue Oct 5, 2016 · 4 comments

Comments

@montaro
Copy link

montaro commented Oct 5, 2016

When I added;

import ipdb
ipdb.set_trace()

into a test case I get the following error:

(xyz-all)➜  xyz git:(xyz-61) ✗ ./manage.py test
nosetests --verbosity=1
Creating test database for alias 'default'...
...E..
======================================================================
ERROR: test_failing_get_or_create_group (zfsb_api.tests.aws.test_aws.TestAWSClient)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/arefaey/workspace/cloud9ers/xyz/xyz/xyz_api/tests/aws/test_aws.py", line 111, in test_failing_get_or_create_group
    ipdb.set_trace()
  File "/Users/arefaey/venvs/xyz-all/lib/python3.5/site-packages/ipdb/__main__.py", line 93, in set_trace
    p = _init_pdb(context).set_trace(frame)
  File "/Users/arefaey/venvs/xyz-all/lib/python3.5/site-packages/ipdb/__main__.py", line 76, in _init_pdb
    p = Pdb(def_colors)
  File "/Users/arefaey/venvs/xyz-all/lib/python3.5/site-packages/IPython/terminal/debugger.py", line 15, in __init__
    self.pt_init()
  File "/Users/arefaey/venvs/xyz-all/lib/python3.5/site-packages/IPython/terminal/debugger.py", line 38, in pt_init
    self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self.shell._eventloop)
AttributeError: 'TerminalInteractiveShell' object has no attribute '_eventloop'

I guess this is related. gotcha/ipdb#105
The error happens when I use django-nose test runner and never happen when I use default django test runner. Any clues?

@JBKahn
Copy link

JBKahn commented Oct 6, 2016

it has to do with the way nose fiddles with stdout by default, in the linked thread we discuss the use of nocapture (with nose) which would circumvent the bug in ipdb.

@jwhitlock
Copy link
Contributor

Agreed, ./manage.py test -s or ./manage.py test --ipdb might help

@jwhitlock
Copy link
Contributor

No response in a month, assuming that helped.

@zsoobhan
Copy link

I know i'm a bit late to the party but using the nose.tools debugger also circumvents the stdout issues.

from nose.tools import set_trace;set_trace()

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

4 participants