调试django / unittest? [英] Debugging django/unittest?

查看:203
本文介绍了调试django / unittest?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道有没有人提到如何调试单元测试,或者django中的其他代码,对于这个问题,使用像winpdb这样的调试器?
我正在尝试一个

  winpdb manage.py test photo 

它为我的照片应用程序运行我的单元测试,但winpdb崩溃。有办法吗这是最好的方法?



我正在运行linux,ubuntu 10.10。

解决方案

您可以使用 pdb 来调试程序。 p>

  import pdb 
def some_function():
pdb.set_trace()
some_other_computation()

当程序命中set_trace方法时,执行将暂停,您将被放入一个交互式shell。然后,您可以检查变量,并逐步执行代码。


I'm wondering if anybody has a hint on how to debug a unittest, or any other piece of code in django, for that matter, using a debugger like winpdb? I'm trying to to a

winpdb manage.py test photo

which runs my unittest for my photo app, but winpdb crashes. Are there alternatives? What is the best way to do this?

I'm running linux, ubuntu 10.10.

解决方案

You can use pdb to debug your program.

import pdb
def some_function():
    pdb.set_trace()
    some_other_computation()

When the program hits the set_trace method, execution will pause, and you will be put into an interactive shell. You can then examine variables, and step through your code.

这篇关于调试django / unittest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆