test def()代码未执行 [英] test def() code not executed

查看:88
本文介绍了test def()代码未执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行manage.py test来测试我的Django模型时,不会执行每个类的每个方法(即def())中定义的代码。但是,如果我将代码移到def之外,但仍然在每个类中都执行

解决方案

您的测试方法必须以测试,这可能是问题。如下:

  def test_some_condition(self):
pass
/ pre>

When I run "manage.py test" to test my Django models, the code defined in each method (ie def()) of each class is not executed. But if I move code outside of def but still in each class it is executed

解决方案

Your test methods have to be prefixed with "test", this might be the issue. As follows:

def test_some_condition(self):
    pass

这篇关于test def()代码未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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