你如何在Django中跳过单元测试? [英] How do you skip a unit test in Django?
问题描述
如何在Django中强制跳过单元测试?
How do forcibly skip a unit test in Django?
@skipif和@skipunless都是我发现的,但我只是想跳过一个测试,现在进行调试
@skipif and @skipunless is all I found, but I just want to skip a test right now for debugging purposes while I get a few things straightened out.
推荐答案
Python的unittest模块有几个装饰器:
Python's unittest module has a few decorators:
有一个简单的旧的 @skip
:
from unittest import skip
@skip("Don't want to test")
def test_something():
...
如果由于某种原因不能使用 @skip
, @skipIf
应该工作。只要把它总是跳过参数 True
:
If you can't use @skip
for some reason, @skipIf
should work. Just trick it to always skip with the argument True
:
@skipIf(True, "I don't want to run this test yet")
def test_something():
...
如果您希望简单地不运行某些测试文件,最好的方法是使用 fab / code>或其他工具,并运行特定测试。
If you are looking to simply not run certain test files, the best way is probably to use fab
or other tool and run particular tests.
这篇关于你如何在Django中跳过单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!