Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #237 from vauxoo-dev/oca-pylint-fix-empty
Browse files Browse the repository at this point in the history
[FIX] test_pylint: Fix empty paths
  • Loading branch information
pedrobaeza committed Aug 30, 2015
2 parents 94bac95 + 34b2629 commit 757515f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
14 changes: 10 additions & 4 deletions travis/run_pylint.py
Expand Up @@ -61,6 +61,9 @@ def run_pylint(paths, cfg, sys_paths=None, extra_params=None):
cmd = ['--rcfile=' + cfg]
cmd.extend(extra_params)
subpaths = get_subpaths(paths)
if not subpaths:
raise ValueError("Python modules not found in paths"
" {paths}".format(paths=paths))
cmd.extend(subpaths)
pylint_res = pylint.lint.Run(cmd, exit=False)
return pylint_res.linter.stats
Expand All @@ -84,10 +87,13 @@ def main(paths, config_file, sys_paths=None, extra_params=None):
to check fails of odoo modules.
If expected errors is equal to count fails found then
this program exit with zero otherwise exit with counted fails"""
stats = run_pylint(
list(paths), config_file.name, sys_paths=sys_paths,
extra_params=extra_params)
count_fails = get_count_fails(stats)
try:
stats = run_pylint(
list(paths), config_file.name, sys_paths=sys_paths,
extra_params=extra_params)
count_fails = get_count_fails(stats)
except ValueError:
count_fails = 0
return count_fails


Expand Down
12 changes: 10 additions & 2 deletions travis/self_tests
Expand Up @@ -32,9 +32,9 @@ assert travis_helpers.green(u'test') == u"\033[1;32mtest\033[0;m"
assert travis_helpers.yellow(u'test') == u"\033[1;33mtest\033[0;m"
assert travis_helpers.yellow_light(u'test') == u"\033[33mtest\033[0;m"

#Testing pylint_run fix of:
# Testing empty paths and pylint_run fix of:
# https://www.mail-archive.com/code-quality@python.org/msg00294.html
if os.environ.get('LINT_CHECK', 0) == 1:
if os.environ.get('LINT_CHECK', 0) == '1':
pylint_rcfile = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'cfg',
Expand All @@ -45,3 +45,11 @@ if os.environ.get('LINT_CHECK', 0) == 1:
"--extra-params", "-e", "--extra-params", "F0010,duplicate-key",
"--path", repo_dir], standalone_mode=False)
assert 1 == count_errors

empty_path = os.path.join(repo_dir, 'empty_path')
if not os.path.exists(empty_path):
os.mkdir(empty_path)
count_errors = run_pylint.main([
"--config-file=" + pylint_rcfile,
"--path", empty_path], standalone_mode=False)
assert -1 == count_errors
6 changes: 3 additions & 3 deletions travis/test_pylint
Expand Up @@ -24,9 +24,9 @@ expected_errors = int(
exit_status = 0
if count_errors != expected_errors:
print("pylint expected errors {expected_errors}, "
"found {number_errors}!".format(
expected_errors=expected_errors,
number_errors=count_errors))
"found {number_errors}!".format(
expected_errors=expected_errors,
number_errors=count_errors))
exit_status = 1

exit(exit_status)

0 comments on commit 757515f

Please sign in to comment.