Do PYTHONPATH shenanigans in run_pylint_on_tests.

If we do it in tox.ini, there are two drawbacks:

- We have more stuff in PYTHONPATH even if we don't when actually using
  qutebrowser.
- The separator is platform specific, so we can't easily do this in a portable
  way in tox.ini.
This commit is contained in:
Florian Bruhin 2015-12-01 08:07:42 +01:00
parent 8be04e4f6c
commit 81f522336f
2 changed files with 14 additions and 4 deletions

View File

@ -47,6 +47,7 @@ def main():
for fn in filenames: for fn in filenames:
if os.path.splitext(fn)[1] == '.py': if os.path.splitext(fn)[1] == '.py':
files.append(os.path.join(dirpath, fn)) files.append(os.path.join(dirpath, fn))
disabled = [ disabled = [
'attribute-defined-outside-init', 'attribute-defined-outside-init',
'redefined-outer-name', 'redefined-outer-name',
@ -56,11 +57,20 @@ def main():
# https://bitbucket.org/logilab/pylint/issue/511/ # https://bitbucket.org/logilab/pylint/issue/511/
'undefined-variable', 'undefined-variable',
] ]
toxinidir = sys.argv[1]
pythonpath = os.environ['PYTHONPATH'].split(os.pathsep) + [
toxinidir,
]
no_docstring_rgx = ['^__.*__$', '^setup$'] no_docstring_rgx = ['^__.*__$', '^setup$']
args = (['--disable={}'.format(','.join(disabled)), args = (['--disable={}'.format(','.join(disabled)),
'--no-docstring-rgx=({})'.format('|'.join(no_docstring_rgx))] + '--no-docstring-rgx=({})'.format('|'.join(no_docstring_rgx))] +
sys.argv[1:] + files) sys.argv[2:] + files)
ret = subprocess.call(['pylint'] + args) env = os.environ.copy()
env['PYTHONPATH'] = os.pathsep.join(pythonpath)
ret = subprocess.call(['pylint'] + args, env=env)
return ret return ret

View File

@ -100,7 +100,7 @@ commands =
basepython = python3 basepython = python3
ignore_errors = true ignore_errors = true
skip_install = true skip_install = true
setenv = PYTHONPATH={toxinidir}/scripts/dev:{toxinidir} setenv = PYTHONPATH={toxinidir}/scripts/dev
passenv = passenv =
deps = deps =
{[testenv]deps} {[testenv]deps}
@ -111,7 +111,7 @@ deps =
commands = commands =
{envpython} scripts/link_pyqt.py --tox {envdir} {envpython} scripts/link_pyqt.py --tox {envdir}
{envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no
{envpython} scripts/dev/run_pylint_on_tests.py --output-format=colorized --reports=no {envpython} scripts/dev/run_pylint_on_tests.py {toxinidir} --output-format=colorized --reports=no
[testenv:pylint-tip] [testenv:pylint-tip]
basepython = python3 basepython = python3