2024-09-26 22:42:04 发布
网友
有了密码
import unittest import time class SleepingTest(unittest.TestCase): def test_that_gets_stuck(self): for a in xrange(100000000000000000): pass
我得到这个输出
如您所见,我使用Ctrl+C来中断程序。但是鼻子说它的测试正常。我更希望它能说测试失败了并给我一个堆栈跟踪。在
有什么方法可以打印出测试卡住的堆栈跟踪吗?在
{a1,尝试进入调试器的信号
import unittest import time from nose.tools import set_trace class SleepingTest(unittest.TestCase): def test_that_gets_stuck(self): try: for a in xrange(10000000): time.sleep(1) except KeyboardInterrupt, err: set_trace()
{a1,尝试进入调试器的信号
相关问题 更多 >
编程相关推荐