Make lints run with adjusted test folder location.
For pylint we need a custom script; see https://bitbucket.org/logilab/pylint/issue/512/
This commit is contained in:
parent
eb76cd71de
commit
d3a92d505c
60
scripts/run_pylint_on_tests.py
Normal file
60
scripts/run_pylint_on_tests.py
Normal file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2014-2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Run pylint on tests.
|
||||
|
||||
This is needed because pylint can't check a folder which isn't a package:
|
||||
https://bitbucket.org/logilab/pylint/issue/512/
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import os.path
|
||||
import subprocess
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
|
||||
|
||||
from scripts import utils
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point.
|
||||
|
||||
Return:
|
||||
The pylint exit status.
|
||||
"""
|
||||
utils.change_cwd()
|
||||
files = []
|
||||
for dirpath, _dirnames, filenames in os.walk('tests'):
|
||||
for fn in filenames:
|
||||
if os.path.splitext(fn)[1] == '.py':
|
||||
files.append(os.path.join(dirpath, fn))
|
||||
disabled = ['attribute-defined-outside-init', 'redefined-outer-name',
|
||||
'unused-argument']
|
||||
no_docstring_rgx = ['^__.*__$', '^setup$']
|
||||
args = (['--disable={}'.format(','.join(disabled)),
|
||||
'--no-docstring-rgx=({})'.format('|'.join(no_docstring_rgx))] +
|
||||
sys.argv[1:] + files)
|
||||
ret = subprocess.call(['pylint'] + args)
|
||||
return ret
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
9
tox.ini
9
tox.ini
@ -44,8 +44,8 @@ commands =
|
||||
[testenv:misc]
|
||||
commands =
|
||||
{envpython} scripts/misc_checks.py git
|
||||
{envpython} scripts/misc_checks.py vcs qutebrowser scripts
|
||||
{envpython} scripts/misc_checks.py spelling qutebrowser scripts
|
||||
{envpython} scripts/misc_checks.py vcs qutebrowser scripts tests
|
||||
{envpython} scripts/misc_checks.py spelling qutebrowser scripts tests
|
||||
|
||||
[testenv:pylint]
|
||||
skip_install = true
|
||||
@ -60,6 +60,7 @@ deps =
|
||||
commands =
|
||||
{[testenv:mkvenv]commands}
|
||||
{envdir}/bin/pylint scripts qutebrowser --rcfile=.pylintrc --output-format=colorized --reports=no
|
||||
{envpython} scripts/run_pylint_on_tests.py --rcfile=.pylintrc --output-format=colorized --reports=no
|
||||
|
||||
[testenv:pep257]
|
||||
skip_install = true
|
||||
@ -68,7 +69,7 @@ deps = pep257==0.5.0
|
||||
# D102: Docstring missing, will be handled by others
|
||||
# D209: Blank line before closing """ (removed from PEP257)
|
||||
# D402: First line should not be function's signature (false-positives)
|
||||
commands = {envpython} -m pep257 scripts qutebrowser --ignore=D102,D209,D402 '--match=(?!resources|test_content_disposition).*\.py'
|
||||
commands = {envpython} -m pep257 scripts tests qutebrowser --ignore=D102,D209,D402 '--match=(?!resources|test_content_disposition).*\.py'
|
||||
|
||||
[testenv:flake8]
|
||||
skip_install = true
|
||||
@ -79,7 +80,7 @@ deps =
|
||||
flake8==2.4.0
|
||||
commands =
|
||||
{[testenv:mkvenv]commands}
|
||||
{envdir}/bin/flake8 scripts qutebrowser --config=.flake8
|
||||
{envdir}/bin/flake8 scripts tests qutebrowser --config=.flake8
|
||||
|
||||
[testenv:pyroma]
|
||||
skip_install = true
|
||||
|
Loading…
Reference in New Issue
Block a user