BryanWheelock
BryanWheelock

Reputation: 12244

Why can't I break into a running test with the pdb interactive debugger?

How can I break into a running test with the pdb interactive debugger?

This is the test:

class UserTestCase(TestCase):
  def test_register_should_create_UserProfile(self):
    c = Client()
    response = c.post('/account/register/', {u'username': [u'john'], u'email': [u'[email protected]'], u'bnewaccount': [u'Signup']})

    self.assertEqual(response.status_code, 302)
    import pdb; pdb.set_trace()
    user = User.objects.get( username ='john')
    self.assertTrue(user.get_profile())

When I attempt to run the tests:
$ python manage.py test

The test database is created. The progress dots '.' begin to progress across the screen as the tests pass. Then the progess stops.

I am never shown a pdb> prompt in the terminal window.

How can I get pdb to work properly?

Upvotes: 1

Views: 490

Answers (1)

Steve Jalim
Steve Jalim

Reputation: 12195

Have you tried ipdb instead of vanilla pdb? I use ipdb and what you're trying to do works fine.

Alternatively, as a fallback, why not try the pdb call inside the method you're testing, just before the response is returned?

Upvotes: 1

Related Questions