klr*_*her 14 python testing functional-testing pytest
我是使用Pytest测试Python的新手,我遇到了一个小而烦人的挂机.在命令行测试会话结果中,我看到我的测试通过,但显示的百分比不是100%.通过一些激进的日志记录,我能够确认我的测试正在按预期传递 - 那么显示的百分比是什么信息?
示例测试会话输出:
platform win32 -- Python 3.7.0a4, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
rootdir: C:\api-check, inifile:
collected 5 items
test_Me.py ... [ 60%]
test_env.py .. [100%]
========================== 5 passed in 6.04 seconds ===========================
Run Code Online (Sandbox Code Playgroud)
iva*_*eev 19
这是一个临时的进度条.
它显示了到目前为止所完成的"工作百分比" - 最有可能的是,完成的测试总数除以运行的测试总数(在开始时预先计算).
如果您的测试运行的时间更长,您可能会看到该行中的数字在通过特定文件进行处理时会发生变化.
iva*_*ncz 10
自 3.3 (2017) 版以来,它是 Pytest 中包含的功能之一。
正如我的同志@ivan_pozdeev提到,这是一个进度指示器,的确。
这是一个示例,您收集了 4 个测试:
$ pytest test.py -v
================================ test session starts =============================
platform linux -- Python 3.6.7, pytest-4.4.0, py-1.8.0, pluggy-0.9.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/ivanleoncz/git/pysd
collected 4 items
test.py::test_active_services PASSED [ 25%]
test.py::test_enabled_services PASSED [ 50%]
test.py::test_is_enabled PASSED [ 75%]
test.py::test_is_active PASSED [100%]
============================== 4 passed in 0.55 seconds ==========================
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2189 次 |
| 最近记录: |