Skip to content

Commit

Permalink
[IMP] test: Add tox for multi-environment and add compatiblity with l…
Browse files Browse the repository at this point in the history
…atest version

Merge pull request #21 from vauxoo-dev/master-oca-update-pylint-astroid-dev-lescobarvx
  • Loading branch information
nhomar committed May 11, 2016
2 parents 7148966 + db782f5 commit 7e99c91
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 19 deletions.
18 changes: 13 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ cache:
directories:
- $HOME/.cache/pip

python:
- "2.7"

addons:
apt:
packages:
Expand All @@ -18,6 +15,15 @@ addons:
virtualenv:
system_site_packages: true

matrix:
include:
- python: 2.7
env:
TOXENV=py27-pylint14
- python: 2.7
env:
TOXENV=py27-pylint20

install:
# Remove packages installed from addons-apt-packages of travis file
- find -L ${TRAVIS_BUILD_DIR} -name requirements.txt -exec sed -i '/lxml/d' {} \;
Expand All @@ -30,13 +36,15 @@ install:
- pip install --upgrade pyopenssl ndg-httpsclient pyasn1
- pip install coveralls flake8

# Install tox
- pip install tox

script:
- flake8 --exclude=__init__.py .
- coverage run setup.py test
- tox -e $TOXENV

after_success:
- coveralls
- coverage report -m
- python setup.py sdist # Build ChangeLog file from git log

deploy:
Expand Down
5 changes: 3 additions & 2 deletions pylint_odoo/augmentations/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ def apply_augmentations(linter):

# W0104 - pointless-statement
# manifest file have a valid pointless-statement dict
suppress_message(linter, BasicChecker.visit_discard,
'W0104', is_manifest_file)
discard = hasattr(BasicChecker, 'visit_discard') and \
BasicChecker.visit_discard or BasicChecker.visit_expr
suppress_message(linter, discard, 'W0104', is_manifest_file)
32 changes: 21 additions & 11 deletions pylint_odoo/checkers/no_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,27 @@
visit_binop
visit_boolop
visit_break
visit_callfunc
visit_class
visit_call
visit_classdef
visit_compare
visit_continue
visit_default
visit_delattr
visit_delname
visit_dict
visit_dictcomp
visit_discard
visit_excepthandler
visit_exec
visit_expr
visit_extslice
visit_for
visit_from
visit_function
visit_importfrom
visit_functiondef
visit_genexpr
visit_getattr
visit_global
visit_if
visit_ifexp
visit_import
visit_index
visit_lambda
visit_listcomp
Expand Down Expand Up @@ -223,9 +222,12 @@ class NoModuleChecker(BaseChecker):
)

@utils.check_messages('translation-field',)
def visit_callfunc(self, node):
def visit_call(self, node):
if node.as_string().lower().startswith('fields.'):
for argument in node.args:
args = hasattr(node, 'keywords') and node.keywords and \
node.args and (node.args + node.keywords) or \
hasattr(node, 'keywords') and node.keywords or node.args
for argument in args:
argument_aux = argument
if isinstance(argument, astroid.Keyword):
argument_aux = argument.value
Expand All @@ -235,6 +237,8 @@ def visit_callfunc(self, node):
self.add_message('translation-field',
node=argument_aux)

visit_callfunc = visit_call

@utils.check_messages('manifest-required-author', 'manifest-required-key',
'manifest-deprecated-key')
def visit_dict(self, node):
Expand Down Expand Up @@ -290,7 +294,7 @@ def visit_dict(self, node):
@utils.check_messages('api-one-multi-together',
'copy-wo-api-one', 'api-one-deprecated',
'method-required-super')
def visit_function(self, node):
def visit_functiondef(self, node):
"""Check that `api.one` and `api.multi` decorators not exists together
Check that method `copy` exists `api.one` decorator
Check deprecated `api.one`.
Expand Down Expand Up @@ -327,22 +331,28 @@ def visit_function(self, node):
self.add_message('method-required-super',
node=node, args=(node.name))

visit_function = visit_functiondef

@utils.check_messages('openerp-exception-warning')
def visit_from(self, node):
def visit_importfrom(self, node):
if node.modname == 'openerp.exceptions':
for (import_name, import_as_name) in node.names:
if import_name == 'Warning' \
and import_as_name != 'UserError':
self.add_message(
'openerp-exception-warning', node=node)

visit_from = visit_importfrom

@utils.check_messages('class-camelcase')
def visit_class(self, node):
def visit_classdef(self, node):
camelized = self.camelize(node.name)
if camelized != node.name:
self.add_message('class-camelcase', node=node,
args=(camelized, node.name))

visit_class = visit_classdef

@utils.check_messages('attribute-deprecated')
def visit_assign(self, node):
node_left = node.targets[0]
Expand Down
2 changes: 1 addition & 1 deletion pylint_odoo/test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
class MainTest(unittest.TestCase):
def setUp(self):
self.default_options = [
'--load-plugins=pylint_odoo', '--report=no',
'--load-plugins=pylint_odoo', '--reports=no',
'--msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}',
'--output-format=colorized',
]
Expand Down
24 changes: 24 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[tox]
envlist = py27-pylint{14,20}
skip_missing_interpreters = true

[base]
deps =
pylint-plugin-utils==0.2.3
docutils==0.12
lxml>=2.3.2
Pygments==2.0.2
restructuredtext_lint==0.12.2
coveralls

[testenv]
deps =
py27-pylint14: astroid==1.3.8
py27-pylint14: pylint==1.4.4
py27-pylint20: git+https://github.com/PyCQA/astroid@master
py27-pylint20: git+https://github.com/PyCQA/pylint@master
{[base]deps}

commands =
coverage run setup.py test
coverage report -m

0 comments on commit 7e99c91

Please sign in to comment.