简体   繁体   English

如何在pytest中添加Flake8配置文件?

[英]How to add Flake8 configuration file in pytest?

I would like to run pytest with Flake8 like this:我想像这样用 Flake8 运行 pytest:

python3 -m pytest --flake8

I also would like to run Flake8 with following parameters:我还想使用以下参数运行 Flake8:

max-line-length = 120
select = E,W,F,N,C

How can I do it?我该怎么做? Creating setup.cfg with this content did not change anything:使用此内容创建setup.cfg不会改变任何内容:

[pytest]
flake8-max-line-length = 120
flake8-select = E,W,F,N,C

Editing pytest.ini (without setup.cfg or any other configuration file) helped my case:编辑pytest.ini (没有 setup.cfg 或任何其他配置文件)对我的情况有帮助:

[pytest]
flake8-select = E,W,F,N,C
flake8-max-line-length = 120
flake8-ignore = E201 E231

Without the flake8-ignore I didn't see any difference in output.如果没有flake8-ignore,我没有看到输出有任何差异。

The pytest section for setup.cfg is [tool:pytest] as of version 4.0 (fully removed in 4.1.0 as per pytest's removal process)对于pytest部setup.cfg[tool:pytest]作为版本4.0 (在4.1.0完全除去每pytest的除去工序)

disclaimer: I'm a core dev of pytest免责声明:我是 pytest 的核心开发人员

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM