我试图通过在包含测试的目录中的命令行调用pytest
命令来运行一些测试。然而,在最后,我只看到有多少测试通过或失败了,但我看不到哪些测试,或者失败的测试产生的回溯(参见下面的屏幕截图)。
在我看到这些东西之前,我不记得Pytest的配置中有任何改变。可能的问题是什么?
更新
更奇怪的是,当我运行一些测试脚本时,我非常确定在单独使用pytest
运行时会显示测试失败,测试通过了:
kurt@kurt-ThinkPad:~/dev/clones6/ipercron-compose/test$ pytest test_api.py
====================== test session starts =======================
platform linux2 -- Python 2.7.12, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /home/kurt/dev/clones6/ipercron-compose/test, inifile:
plugins: flask-0.10.0
collected 5 items
test_api.py .....
==================== 5 passed in 4.20 seconds ====================
kurt@kurt-ThinkPad:~/dev/clones6/ipercron-compose/test$ pytest test_furion.py
====================== test session starts =======================
platform linux2 -- Python 2.7.12, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /home/kurt/dev/clones6/ipercron-compose/test, inifile:
plugins: flask-0.10.0
collected 6 items
test_furion.py ......
==================== 6 passed in 7.84 seconds ====================
kurt@kurt-ThinkPad:~/dev/clones6/ipercron-compose/test$ pytest test_furion2.py
====================== test session starts =======================
platform linux2 -- Python 2.7.12, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /home/kurt/dev/clones6/ipercron-compose/test, inifile:
plugins: flask-0.10.0
collected 4 items
test_furion2.py ....
=================== 4 passed in 12.91 seconds ====================
使用pytest
命令或pytest [filename]
命令调用测试会有什么不同吗?
发布于 2021-03-01 14:47:14
您可以使用
pytest -h
以显示有关可能的标志和选项的所有信息。但是,将更多信息添加到测试中的最简单方法是添加详细详细标志--增加详细程度。
pytest your_test.py -v
f.i.如果您在测试中使用了print()语句,那么添加-s会在运行时显示所有结果。
pytest your_test.py -v -s
发布于 2018-01-30 02:41:19
我会安装pytest-html。这样就可以修复终端输出的潜在问题。
https://stackoverflow.com/questions/42201439
复制相似问题