diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-12-09 07:16:53 -0500 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-12-09 07:17:30 -0500 |
commit | bf2ee31f956447fa42ae85dc69820405eda8c490 (patch) | |
tree | eec86ef2d4b36942fe554a7784f39572b5bcfe6b | |
parent | 14578f009d568850a918930180600807baa6c194 (diff) | |
download | bcfg2-bf2ee31f956447fa42ae85dc69820405eda8c490.tar.gz bcfg2-bf2ee31f956447fa42ae85dc69820405eda8c490.tar.bz2 bcfg2-bf2ee31f956447fa42ae85dc69820405eda8c490.zip |
testsuite: made pylint tests at least kinda work with pylint 1.0
They still don't pass, partially due to what appear to be bugs in
pylint and partially due to a few new things that pylint is checking
for in 1.0, but we don't use pylint 1.0 in travis-ci so i'm not
terribly worried about that right now.
-rw-r--r-- | testsuite/ext/exception_messages.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/testsuite/ext/exception_messages.py b/testsuite/ext/exception_messages.py index 877ba42a1..cd3d7112c 100644 --- a/testsuite/ext/exception_messages.py +++ b/testsuite/ext/exception_messages.py @@ -1,16 +1,30 @@ -from logilab import astng -from pylint.interfaces import IASTNGChecker +try: + from logilab import astng as ast + from pylint.interfaces import IASTNGChecker as IChecker + PYLINT = 0 # pylint 0.something +except ImportError: + import astroid as ast + from pylint.interfaces import IAstroidChecker as IChecker + PYLINT = 1 # pylint 1.something from pylint.checkers import BaseChecker from pylint.checkers.utils import safe_infer +if PYLINT == 0: + # this is not quite correct; later versions of pylint 0.* wanted a + # three-tuple for messages as well + msg = ('Exception raised without arguments', + 'Used when an exception is raised without any arguments') +else: + msg = ('Exception raised without arguments', + 'exception-without-args', + 'Used when an exception is raised without any arguments') +msgs = {'R9901': msg} + class ExceptionMessageChecker(BaseChecker): - __implements__ = IASTNGChecker + __implements__ = IChecker name = 'Exception Messages' - msgs = \ - {'R9901': ('Exception raised without arguments', - 'Used when an exception is raised without any arguments')} options = ( ('exceptions-without-args', dict(default=('NotImplementedError',), @@ -23,9 +37,9 @@ class ExceptionMessageChecker(BaseChecker): def visit_raise(self, node): if node.exc is None: return - if isinstance(node.exc, astng.Name): + if isinstance(node.exc, ast.Name): raised = safe_infer(node.exc) - if (isinstance(raised, astng.Class) and + if (isinstance(raised, ast.Class) and raised.name not in self.config.exceptions_without_args): self.add_message('R9901', node=node.exc) |