python-3.x - 与 python3.6 相比,使用 python3.7 的 pytest 运行时间几乎长 10 倍
问题描述
我正在一个名为 pdf2textbox 的模块上运行 pytests,为此我使用了 tox。python 3.5、3.6 和 3.7 的设置是相同的:
# tox.ini
...
[testenv]
basepyton =
py35: python3.5
py36: python3.6
py37: python3.7
deps =
check-manifest
pytest
requests
pdfminer2
pytest-cov
commands =
check-manifest
python --version
py.test --cov=pdf2textbox tests
当我运行 tox 时,python3.5 和 python3.6 的时间大约是 58 或 59 秒。但是,python3.7 大约需要 8 分钟:
py36 inst-nodeps: .../.virtualenvs/pdf2textbox/.tox/dist/pdf2textbox-0.2.6.zip
py36 installed: atomicwrites==1.1.5,attrs==18.1.0,certifi==2018.4.16,chardet==3.0.4,check-manifest==0.37,coverage==4.5.1,idna==2.7,more-itertools==4.2.0, pdf2textbox==0.2.6, pdfminer2==20151206,pluggy==0.6.0,py==1.5.4,pytest==3.6.3,pytest-cov==2.5.1, requests==2.19.1, six==1.11.0,urllib3==1.23
py36 runtests: PYTHONHASHSEED='1111111111'
py36 runtests: commands[0] | check-manifest
some files listed as being under source control are missing:
.tox/dist/pdf2textbox-0.2.4.zip
lists of files in version control and sdist match
py36 runtests: commands[1] | python --version
Python 3.6.3
py36 runtests: commands[2] | py.test --cov=pdf2textbox tests
============================ test session starts =============================
platform linux -- Python 3.6.3, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: .../.virtualenvs/pdf2textbox, inifile:
plugins: cov-2.5.1
collected 15 items
tests/test_cli_slice_option.py ... [ 20%]
tests/test_convert_pdf.py ........ [ 60%]
tests/test_get_pdf.py ............ [ 86%]
tests/test_types.py .............. [100%]
----------- coverage: platform linux, python 3.6.3-final-0 -----------
Name Stmts Miss Cover
pdf2textbox/__init__.py 1 0 100%
pdf2textbox/pdf2textbox.py 507 201 60%
TOTAL 508 201 60%
**================== 15 passed in 58.93 seconds ==============================**
py37 inst-nodeps: .../.virtualenvs/pdf2textbox/.tox/dist/pdf2textbox-0.2.6.zip
py37 installed: atomicwrites==1.1.5,attrs==18.1.0,certifi==2018.4.16,chardet==3.0.4,check-manifest==0.37,coverage==4.5.1,idna==2.7,more-itertools==4.2.0,pdf2textbox==0.2.6,pdfminer2==20151206,pluggy==0.6.0,py==1.5.4,pytest==3.6.3,pytest-cov==2.5.1,requests==2.19.1,six==1.11.0,urllib3==1.23
py37 runtests: PYTHONHASHSEED='2222222222'
py37 runtests: commands[0] | check-manifest
some files listed as being under source control are missing:
.tox/dist/pdf2textbox-0.2.4.zip
lists of files in version control and sdist match
py37 runtests: commands[1] | python --version
Python 3.7.0b3
py37 runtests: commands[2] | py.test --cov=pdf2textbox tests
========================== test session starts =================================
platform linux -- Python 3.7.0b3, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: .../.virtualenvs/pdf2textbox, inifile:
plugins: cov-2.5.1 collected 15 items
tests/test_cli_slice_option.py ... [ 20%]
tests/test_convert_pdf.py ........ [ 60%]
tests/test_get_pdf.py ............ [ 86%]
tests/test_types.py .............. [100%]
----------- coverage: platform linux, python 3.7.0-beta-3 -----------
Name Stmts Miss Cover
pdf2textbox/__init__.py 1 0 100%
pdf2textbox/pdf2textbox.py 507 201 60%
TOTAL 508 201 60%
**=================== 15 passed in 461.68 seconds =============================**
_______________________________ summary _______________________________________
py35: commands succeeded
py36: commands succeeded
py37: commands succeeded
congratulations :)
测试时间:
py35:1 分钟
py36:1 分钟
py37:8 分钟
有谁知道为什么会这样?
解决方案
推荐阅读
- c# - 如何使用绑定将数据从 SQL 检索到文本框中?
- python - AttributeError: NDARRAY_SPEC 在导入 tensorflow 时
- amazon-web-services - 如何使无法访问互联网的EC2实例访问同一帐户中的资源?
- javascript - 发出套接字 io 事件时更改状态
- fullcalendar - 有没有办法在 Fullcalendar v5 resourceTimeline 视图上扩展上一个和下一个点击事件的资源?
- r-exams - Exams2canvas 与 Canvas 新测验格式兼容吗?
- c - C语言中的scanf
- java - 强制类型而不创建临时变量
- javascript - 如何显示角度验证器的错误?
- python - Python中的过滤字符串