gpt4 book ai didi

python - 如何查看在 Django 的 manage.py test 命令期间运行了哪些测试

转载 作者:IT老高 更新时间:2023-10-28 21:40:38 33 4
gpt4 key购买 nike

使用 Django 的 manage.py test 命令完成测试执行后,只有通过的测试数量会打印到控制台。

(virtualenv) G:\Project\>python manage.py test
Creating test database for alias 'default'...
True
..
----------------------------------------------------------------------
Ran 2 tests in 0.017s

OK
Destroying test database for alias 'default'...

有什么办法可以看到:

  1. 实际执行了哪些测试
  2. 来自哪个模块
  3. 按什么顺序

我在文档中没有找到任何解决方案。

最佳答案

您可以将 -v 2 传递给 test 命令:

python manage.py test -v 2

运行此命令后,您将得到类似的结果(我使用的是 django 2,请随意忽略迁移/数据库的内容):

Creating test database for alias 'default' ('file:memorydb_default?mode=memory&cache=shared')...
Operations to perform:
Synchronize unmigrated apps: messages, staticfiles
Apply all migrations: admin, auth, contenttypes, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Running migrations:
Applying contenttypes.0001_initial... OK
...
Applying sessions.0001_initial... OK
System check identified no issues (0 silenced).
test_equal_hard (polls.tests.TestHard) ... ok <--------+
test_equal_simple (polls.tests.TestSimple) ... ok <--------+
|
|
That's your tests! >----------------------------+

顺便说一下,v代表verbosity(你也可以使用--verbosity=2):

python manage.py test --verbosity=2

这是python manage.py test --help的摘录:

-v {0,1,2,3}, --verbosity {0,1,2,3}

Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output

关于python - 如何查看在 Django 的 manage.py test 命令期间运行了哪些测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21500354/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com