Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

pylint

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?

like image 688
yegor256 Avatar asked Mar 04 '14 18:03

yegor256


1 Answers

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
like image 135
Bartek Jablonski Avatar answered Sep 28 '22 05:09

Bartek Jablonski