Skip to content

Commit

Permalink
Merge pull request #91 from vauxoo-dev/master-oca-fix-global-moy
Browse files Browse the repository at this point in the history
[FIX] test: Never use global into test

* [REF] misc: Remove deprecated method
  • Loading branch information
pedrobaeza authored Dec 21, 2016
2 parents cde2c3c + fd52d66 commit 2370e52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
10 changes: 0 additions & 10 deletions pylint_odoo/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ def get_plugin_msgs(pylint_run_res):
return all_plugin_msgs


def get_sum_fails(pylint_stats):
"""Get a sum of all fails.
:param pylint_stats: Object returned by pylint.run method.
:return: Integer with sum of all errors found.
"""
return sum([
pylint_stats['by_msg'][msg]
for msg in pylint_stats['by_msg']])


def join_node_args_kwargs(node):
"""Method to join args and keywords
:param node: node to get args and keywords
Expand Down
29 changes: 13 additions & 16 deletions pylint_odoo/test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def setUp(self):
self.profile = Profile()
self.sys_path_origin = list(sys.path)
self.maxDiff = None
self.expected_errors = EXPECTED_ERRORS

def tearDown(self):
sys.path = list(self.sys_path_origin)
Expand All @@ -108,41 +109,37 @@ def run_pylint(self, paths, extra_params=None):
return res

def test_10_path_dont_exist(self):
"self-test if path don't exist"
"""test if path don't exist"""
path_unexist = u'/tmp/____unexist______'
with self.assertRaisesRegexp(
OSError,
r'Path "{path}" not found.$'.format(path=path_unexist)):
self.run_pylint([path_unexist])

def test_20_expected_errors(self):
"""Expected vs found errors"""
pylint_res = self.run_pylint(self.paths_modules)
# Expected vs found errors
real_errors = pylint_res.linter.stats['by_msg']
self.assertEqual(EXPECTED_ERRORS, real_errors)
# All odoolint name errors vs found
self.assertEqual(self.expected_errors, real_errors)

def test_25_checks_without_coverage(self):
"""All odoolint errors vs found"""
pylint_res = self.run_pylint(self.paths_modules)
msgs_found = pylint_res.linter.stats['by_msg'].keys()
plugin_msgs = misc.get_plugin_msgs(pylint_res)
test_missed_msgs = sorted(list(set(plugin_msgs) - set(msgs_found)))
self.assertEqual(
test_missed_msgs, [],
self.assertFalse(
test_missed_msgs,
"Checks without test case: {test_missed_msgs}".format(
test_missed_msgs=test_missed_msgs))
sum_fails_found = misc.get_sum_fails(pylint_res.linter.stats)
sum_fails_expected = sum(EXPECTED_ERRORS.values())
self.assertEqual(sum_fails_found, sum_fails_expected)

def test_30_disabling_errors(self):
# Disabling
"""Test disabling checkers"""
self.default_extra_params.append('--disable=dangerous-filter-wo-user')
pylint_res = self.run_pylint(self.paths_modules)
real_errors = pylint_res.linter.stats['by_msg']
global EXPECTED_ERRORS
EXPECTED_ERRORS.pop('dangerous-filter-wo-user')
self.assertEqual(EXPECTED_ERRORS, real_errors)
sum_fails_found = misc.get_sum_fails(pylint_res.linter.stats)
sum_fails_expected = sum(EXPECTED_ERRORS.values())
self.assertEqual(sum_fails_found, sum_fails_expected)
self.expected_errors.pop('dangerous-filter-wo-user')
self.assertEqual(self.expected_errors, real_errors)

def test_40_deprecated_modules(self):
"""Test deprecated modules"""
Expand Down

0 comments on commit 2370e52

Please sign in to comment.