summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pylint/interfaces.py2
-rw-r--r--pylint/lint.py4
-rw-r--r--pylint/reporters/__init__.py8
-rw-r--r--pylint/test/test_functional.py2
-rw-r--r--pylint/test/test_self.py2
-rw-r--r--pylint/test/unittest_reporters_json.py2
-rw-r--r--pylint/test/unittest_reporting.py22
-rw-r--r--pylint/testutils.py2
8 files changed, 34 insertions, 10 deletions
diff --git a/pylint/interfaces.py b/pylint/interfaces.py
index c7791e523..d58ff4a6b 100644
--- a/pylint/interfaces.py
+++ b/pylint/interfaces.py
@@ -90,7 +90,7 @@ class IReporter(Interface):
def handle_message(self, msg):
"""Handle the given message object."""
- def display_results(self, layout):
+ def display_reports(self, layout):
"""display results encapsulated in the layout tree
"""
diff --git a/pylint/lint.py b/pylint/lint.py
index f480139dc..011aff16e 100644
--- a/pylint/lint.py
+++ b/pylint/lint.py
@@ -972,7 +972,7 @@ class PyLinter(config.OptionsManagerMixIn,
else:
sect = report_nodes.Section()
if self.config.reports or self.config.output_format == 'html':
- self.reporter.display_results(sect)
+ self.reporter.display_reports(sect)
# save results if persistent run
if self.config.persistent:
config.save_results(self.stats, self.file_state.base_name)
@@ -981,7 +981,7 @@ class PyLinter(config.OptionsManagerMixIn,
# No output will be emitted for the html
# reporter if the file doesn't exist, so emit
# the results here.
- self.reporter.display_results(report_nodes.Section())
+ self.reporter.display_reports(report_nodes.Section())
self.reporter.on_close(self.stats, {})
# specific reports ########################################################
diff --git a/pylint/reporters/__init__.py b/pylint/reporters/__init__.py
index 01129fb02..a5a2cc316 100644
--- a/pylint/reporters/__init__.py
+++ b/pylint/reporters/__init__.py
@@ -79,13 +79,19 @@ class BaseReporter(object):
"""write a line in the output buffer"""
print(self.encode(string), file=self.out)
- def display_results(self, layout):
+ def display_reports(self, layout):
"""display results encapsulated in the layout tree"""
self.section = 0
if hasattr(layout, 'report_id'):
layout.children[0].children[0].data += ' (%s)' % layout.report_id
self._display(layout)
+ def display_results(self, layout):
+ warnings.warn("display_results is deprecated, use display_reports instead. "
+ "The former will be removed in Pylint 2.0.",
+ DeprecationWarning)
+ self.display_reports(layout)
+
def _display(self, layout):
"""display the layout"""
raise NotImplementedError()
diff --git a/pylint/test/test_functional.py b/pylint/test/test_functional.py
index 09d3934e0..7da9e55a8 100644
--- a/pylint/test/test_functional.py
+++ b/pylint/test/test_functional.py
@@ -88,7 +88,7 @@ class TestReporter(reporters.BaseReporter):
def on_set_current_module(self, module, filepath):
self.messages = []
- def display_results(self, layout):
+ def display_reports(self, layout):
"""Ignore layouts."""
diff --git a/pylint/test/test_self.py b/pylint/test/test_self.py
index 831cdb990..de3dc648e 100644
--- a/pylint/test/test_self.py
+++ b/pylint/test/test_self.py
@@ -56,7 +56,7 @@ class MultiReporter(BaseReporter):
for rep in self._reporters:
rep.handle_message(msg)
- def display_results(self, layout):
+ def display_reports(self, layout):
pass
@property
diff --git a/pylint/test/unittest_reporters_json.py b/pylint/test/unittest_reporters_json.py
index 1b0ae1d56..39b05b8f6 100644
--- a/pylint/test/unittest_reporters_json.py
+++ b/pylint/test/unittest_reporters_json.py
@@ -40,7 +40,7 @@ class TestJSONReporter(unittest.TestCase):
linter.add_message('line-too-long', line=1, args=(1, 2))
# we call this method because we didn't actually run the checkers
- reporter.display_results(None)
+ reporter.display_reports(None)
expected_result = [[
("column", 0),
("line", 1),
diff --git a/pylint/test/unittest_reporting.py b/pylint/test/unittest_reporting.py
index 621c196bb..4edf8cad7 100644
--- a/pylint/test/unittest_reporting.py
+++ b/pylint/test/unittest_reporting.py
@@ -108,7 +108,7 @@ class PyLinterTC(unittest.TestCase):
linter.open()
linter.set_current_module('0123')
linter.add_message('lowercase-l-suffix', line=1)
- linter.reporter.display_results(Section())
+ linter.reporter.display_reports(Section())
self.assertEqual(output.getvalue().splitlines(), expected)
@unittest.expectedFailure
@@ -154,8 +154,26 @@ a&lt; 5: print "zero"</td>
linter.add_message('bad-whitespace', line=1,
args=('Exactly one', 'required', 'before',
'comparison', 'a< 5: print "zero"'))
- linter.reporter.display_results(Section())
+ linter.reporter.display_reports(Section())
self.assertMultiLineEqual(output.getvalue(), expected)
+ def test_display_results_is_renamed(self):
+ class CustomReporter(TextReporter):
+ def _display(self, layout):
+ return None
+
+ reporter = CustomReporter()
+ if __pkginfo__.numversion >= (2, 0):
+ with self.assertRaises(AttributeError):
+ reporter.display_results
+ else:
+ with warnings.catch_warnings(record=True) as cm:
+ warnings.simplefilter("always")
+ reporter.display_results(Section())
+
+ self.assertEqual(len(cm), 1)
+ self.assertIsInstance(cm[0].message, DeprecationWarning)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/pylint/testutils.py b/pylint/testutils.py
index f8906fbf4..e0580253e 100644
--- a/pylint/testutils.py
+++ b/pylint/testutils.py
@@ -128,7 +128,7 @@ class TestReporter(BaseReporter):
self.reset()
return result
- def display_results(self, layout):
+ def display_reports(self, layout):
"""ignore layouts"""
_display = None