[英]Python coverage used in Django takes too long to execute even though it is run with --source flag option
我将 Python 包与 Django 测试框架结合使用,有时只想测试 coverage --source 选项中声明的一个应用程序/目录/包。
coverage run --source='custom_auth' manage.py test custom_auth.tests.TestAuth.test_authentication --keepdb
这个命令是只运行一个测试的正确方法吗? 我还使用 --keepdb 命令忽略再次重新创建数据库。 测试在 0.147s 内执行,但测试前后发生了一些事情,大约需要 3-5 分钟才能开始执行测试。
另一种可能更容易记住的方法是标记您的测试
from django.test import tag
class Tests(TestCase):
@tag('eu')
def test_001_default(self):
...
@tag('eu','invoice')
def test001_invoice(self):
...
@tag('eu','shipment', 'slow')
def test_001_shipment(self):
...
然后
./manage.py test --keepdb whatever.tests --tag=eu
要么
./manage.py test --keepdb whatever.tests.name.Tests --tag=eu --exclude-tag=slow
等等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.