[英]Exception in thread during testing
I run my tests: 我运行测试:
manage.py test myapp
and at the end I get: 最后我得到:
Ran 22 tests in 7.243s
在7.243秒内进行了22次测试
OK
好
Exception in thread Thread-22 (most likely raised during interpreter shutdown)
线程Thread-22中的异常(很可能在解释器关闭期间引发)
or 要么
Ran 22 tests in 7.243s
在7.243秒内进行了22次测试
OK
好
Unhandled exception in thread started by < function observe at ... > ...
由<函数启动的线程中未处理的异常在...> ...观察
or simple 或简单
Ran 22 tests in 7.243s
在7.243秒内进行了22次测试
OK
好
Function observe() is not called during testing (it is a separate thread), but I am getting above exceptions... 在测试过程中未调用函数observe() (它是一个单独的线程),但是我遇到了异常...
What should I do in order to tests omitted this function? 为了测试省略了该功能我该怎么办?
Wrapping the run()
method of the threads into try
/ except
can help: 将线程的
run()
方法包装为try
/ except
可以帮助:
import traceback
class MyThread(Thread):
def run(self):
try:
oldRun(self)
except:
traceback.print_exc()
def oldRun(self):
# insert here the code from the original run function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.