我正在尝试将所有 .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/