How to make pylint a part of setup.py test process?

I'm trying to add pylint checking of all .py files to the test process of setuptools (maybe I'm doing something wrong, please correct me). This is what I'm doing in 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},
...

)

When I run python setup.py test the output looks broken.. Am I doing it right?


Configuration working for me: In setup.py :

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

In setup.cfg :

[aliases]
test=pytest

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

Then you can run pylint just by typing:

python setup.py test

如果你已经在使用py.test ,你应该把它添加到你的setup.cfg

[pytest]
addopts = --pylint
链接地址: http://www.djcxy.com/p/19278.html

上一篇: li上的类的字体颜色不会呈现,直到在Chrome中不重点为止

下一篇: 如何使pylint成为setup.py测试过程的一部分?