summaryrefslogtreecommitdiff
path: root/testutils.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2014-08-29 11:16:29 -0400
committerBrett Cannon <brett@python.org>2014-08-29 11:16:29 -0400
commit29bb89fe46c7b65df777e626cac5611961a9d325 (patch)
treeac54ba8376a81bc20498fa2da6db810d06be9ac6 /testutils.py
parent41bd5fd5d79925b41e72add687ede9a065f6de10 (diff)
downloadpylint-git-29bb89fe46c7b65df777e626cac5611961a9d325.tar.gz
Modernize to the point of working for Python 2.7 still
--HG-- branch : python_6
Diffstat (limited to 'testutils.py')
-rw-r--r--testutils.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/testutils.py b/testutils.py
index 86539acb4..6a437c6e7 100644
--- a/testutils.py
+++ b/testutils.py
@@ -14,6 +14,7 @@
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""functional/non regression tests for pylint"""
+from __future__ import print_function
import collections
import contextlib
@@ -34,6 +35,7 @@ from pylint.utils import PyLintASTWalker
from pylint.reporters import BaseReporter
from pylint.interfaces import IReporter
from pylint.lint import PyLinter
+import six
# Utils
@@ -113,7 +115,7 @@ class TestReporter(BaseReporter):
def finalize(self):
self.messages.sort()
for msg in self.messages:
- print >> self.out, msg
+ print(msg, file=self.out)
result = self.out.getvalue()
self.reset()
return result
@@ -148,7 +150,7 @@ class UnittestLinter(object):
return True
def add_stats(self, **kwargs):
- for name, value in kwargs.iteritems():
+ for name, value in six.iteritems(kwargs):
self.stats[name] = value
return self.stats
@@ -161,7 +163,7 @@ def set_config(**kwargs):
def _Wrapper(fun):
@functools.wraps(fun)
def _Forward(self):
- for key, value in kwargs.iteritems():
+ for key, value in six.iteritems(kwargs):
setattr(self.checker.config, key, value)
if isinstance(self, CheckerTestCase):
# reopen checker in case, it may be interested in configuration change
@@ -180,7 +182,7 @@ class CheckerTestCase(unittest.TestCase):
def setUp(self):
self.linter = UnittestLinter()
self.checker = self.CHECKER_CLASS(self.linter) # pylint: disable=not-callable
- for key, value in self.CONFIG.iteritems():
+ for key, value in six.iteritems(self.CONFIG):
setattr(self.checker.config, key, value)
self.checker.open()
@@ -277,11 +279,11 @@ class LintTestUsingModule(unittest.TestCase):
self.linter.disable('I')
try:
self.linter.check(tocheck)
- except Exception, ex:
+ except Exception as ex:
# need finalization to restore a correct state
self.linter.reporter.finalize()
ex.file = tocheck
- print ex
+ print(ex)
ex.__str__ = exception_str
raise
self._check_result(self.linter.reporter.finalize())