gpt4 book ai didi

python - 如何使 pylint 成为 setup.py 测试过程的一部分?

转载 作者:太空狗 更新时间:2023-10-29 18:34:18 33 4
gpt4 key购买 nike

我正在尝试将所有 .py 文件的 pylint 检查添加到 setuptools 的 test 过程中(也许我正在做一些事情有误,请指正)。这就是我在 setup.py 中所做的:

class MyTest(test):
def run_tests(self):
import pytest
import pylint
if (pylint.run_pylint()):
sys.exit(-1)
if (pytest.main(self.test_args)):
sys.exit(-1)
setup(
tests_require = ['pytest', 'pylint'],
cmdclass = {'test': MyTest},
...

)

当我运行 python setup.py test 时,输出看起来很糟糕。我做对了吗?

最佳答案

适合我的配置:在 setup.py 中:

setup(
name='...',
setup_requires=['pytest-runner', 'pytest-pylint', ...],
tests_require=['pytest', 'pylint']
...
)

setup.cfg中:

[aliases]
test=pytest

[pytest]
addopts = --pylint --pylint-rcfile=...

然后你可以通过输入运行pylint:

python setup.py test

关于python - 如何使 pylint 成为 setup.py 测试过程的一部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22180315/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com