pytest需要很长时间来收集测试

时间:2016-10-07 23:09:02

标签: pytest

我有一个带有1个测试的小项目需要很长时间才能收集。我已经对集合和集合报告进行了记录。在22:51:59到22:52:04之间,我不确定发生了什么,但是那个(闲置?)暂停发生的地方。

[pytest]
testpaths = myproject/tests
python_files = *.py
addopts = -s
norecursedirs = docs *.egg-info .git appdir .tox __pycache__ .cache

root@0d696173168f:/var/www/myproject# pytest myproject/tests/redis/
================================= test session starts =================================
platform linux -- Python 3.5.2, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
rootdir: /var/www/myproject, inifile: pytest.ini
22:51:59: collection started
22:51:59: collecting file: /var/www/myproject/myproject/tests/redis/__init__.py
22:51:59: collecting file: /var/www/myproject/myproject/tests/redis/pubsub.py
collecting 0 items22:51:59: collection report: <CollectReport '' lenresult=2 outcome='passed'>
22:51:59: collection started
collecting 0 items22:52:04: collection report: <CollectReport 'myproject/tests/redis/__init__.py' lenresult=0 outcome='passed'>
22:52:04: collection started
22:52:04: collection started
collecting 0 items22:52:04: collection report: <CollectReport 'myproject/tests/redis/pubsub.py::RedisTest' lenresult=0 outcome='passed'>
22:52:04: collection started
22:52:04: collected item: <TestCaseFunction 'test_pass'>
collecting 1 items22:52:04: collection report: <CollectReport 'myproject/tests/redis/pubsub.py::RegisterTests' lenresult=1 outcome='passed'>
collecting 1 items22:52:04: collection report: <CollectReport 'myproject/tests/redis/pubsub.py' lenresult=2 outcome='passed'>
collected 1 items

myproject/tests/redis/pubsub.py .

============================== 1 passed in 5.64 seconds ===============================

1 个答案:

答案 0 :(得分:0)

如果不查看测试代码,很难说清楚。

我建议您确保在测试模块中只有测试功能/类和/或灯具。原因是任何&#34;解开&#34;测试模块中的代码将在收集阶段由pytest执行。