2024-06-09 20:53:44 发布
网友
我正在使用pytest-flake8插件来lint我的Python代码。 每次我都是这样运行的:
pytest --flake8
除了linting之外,还运行所有测试。 但我只想检查一下皮棉。在
我如何配置pytest,使其只对代码进行lint处理,而跳过我的所有测试,最好是通过命令行(或conftest.py)-而不必在我的测试中添加跳过标记?在
您可以自己更改测试运行逻辑,例如,当 flake8arg通过时忽略收集的测试:
flake8
# conftest.py def pytest_collection_modifyitems(session, config, items): if config.getoption(' flake8'): items[:] = [item for item in items if item.get_marker('flake8')]
现在只执行flake8测试,其余的将被忽略。在
我也遇到了同样的问题,经过一番挖掘,我意识到我只想运行flake8:
flake8 <path to folder>
就这样。不需要运行其他任何东西,因为您的flake8configuration独立于PyTest。在
您可以自己更改测试运行逻辑,例如,当
flake8
arg通过时忽略收集的测试:现在只执行flake8测试,其余的将被忽略。在
我也遇到了同样的问题,经过一番挖掘,我意识到我只想运行
flake8
:flake8 <path to folder>
就这样。不需要运行其他任何东西,因为您的
flake8
configuration独立于PyTest。在相关问题 更多 >
编程相关推荐