为什么我不能使用pdb交互式调试器进入运行测试?

时间:2010-02-24 14:00:20

标签: python django testing pdb

如何使用pdb交互式调试器进入运行测试?

这是测试:

class UserTestCase(TestCase):
  def test_register_should_create_UserProfile(self):
    c = Client()
    response = c.post('/account/register/', {u'username': [u'john'], u'email': [u'john@beatles.com'], 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())

当我尝试运行测试时:
$ python manage.py test

创建测试数据库。进步点'。'当测试通过时,开始在屏幕上前进。 然后,progess停止。

我从未出现过pdb>在终端窗口提示。

如何让pdb正常工作?

1 个答案:

答案 0 :(得分:1)

您是否尝试过ipdb而不是vanilla pdb?我使用ipdb,你正在尝试做的工作正常。

或者,作为回退,为什么不在返回响应之前尝试在您正在测试的方法中进行pdb调用?

相关问题