13

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?

yegor256
  • 102,010
  • 123
  • 446
  • 597

2 Answers2

5

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
Bartek Jablonski
  • 2,649
  • 24
  • 32
1

If you are already using py.test, you can install pytest-pylint and add this to your setup.cfg:

[tool:pytest]
addopts = --pylint
Mr. S
  • 1,469
  • 2
  • 15
  • 27
sorin
  • 161,544
  • 178
  • 535
  • 806