Merge lp:~adiroiban/pocket-lint/bug-761572 into lp:pocket-lint

Proposed by Curtis Hovey
Status: Merged
Approved by: Curtis Hovey
Approved revision: 367
Merged at revision: 371
Proposed branch: lp:~adiroiban/pocket-lint/bug-761572
Merge into: lp:pocket-lint
Diff against target: 100 lines (+13/-1)
3 files modified
pocketlint/formatcheck.py (+5/-1)
pocketlint/tests/__init__.py (+2/-0)
pocketlint/tests/test_python.py (+6/-0)
To merge this branch: bzr merge lp:~adiroiban/pocket-lint/bug-761572
Reviewer Review Type Date Requested Status
Curtis Hovey curtis Approve
Review via email: mp+58037@code.launchpad.net

Description of the change

Return the count of messages, zero indicating no issues.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you very much for this patch. I am merging it and intend to release it with version 0.5.14.

review: Approve (curtis)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'pocketlint/formatcheck.py'
2--- pocketlint/formatcheck.py 2011-04-17 16:22:10 +0000
3+++ pocketlint/formatcheck.py 2011-04-17 16:27:29 +0000
4@@ -65,10 +65,12 @@
5 self.treestore = self.file_lines_view.get_model()
6 self.piter = None
7 self._last_file_name = None
8+ self.call_count = 0
9
10 def __call__(self, line_no, message, icon=None,
11 base_dir=None, file_name=None):
12 """Report a message."""
13+ self.call_count += 1
14 if self.report_type == self.FILE_LINES:
15 self._message_file_lines(
16 line_no, message, icon=icon,
17@@ -545,6 +547,7 @@
18 def check_sources(sources, reporter=None):
19 if reporter is None:
20 reporter = Reporter(Reporter.CONSOLE)
21+ reporter.call_count = 0
22 for source in sources:
23 file_path = os.path.normpath(source)
24 if os.path.isdir(source) or not Language.is_editable(source):
25@@ -555,6 +558,7 @@
26 checker = UniversalChecker(
27 file_path, text=text, language=language, reporter=reporter)
28 checker.check()
29+ return reporter.call_count
30
31
32 def main(argv=None):
33@@ -569,7 +573,7 @@
34 if options.verbose:
35 pass
36 reporter = Reporter(Reporter.CONSOLE)
37- check_sources(sources, reporter)
38+ return check_sources(sources, reporter)
39
40
41 if __name__ == '__main__':
42
43=== modified file 'pocketlint/tests/__init__.py'
44--- pocketlint/tests/__init__.py 2011-03-27 18:07:20 +0000
45+++ pocketlint/tests/__init__.py 2011-04-17 16:27:29 +0000
46@@ -9,10 +9,12 @@
47
48 def __init__(self):
49 self.messages = []
50+ self.call_count = 0
51
52 def __call__(self, line_no, message, icon=None,
53 base_dir=None, file_name=None):
54 """Report a message."""
55+ self.call_count += 1
56 self._message_console(
57 line_no, message, icon=icon,
58 base_dir=base_dir, file_name=file_name)
59
60=== modified file 'pocketlint/tests/test_python.py'
61--- pocketlint/tests/test_python.py 2011-04-17 14:41:15 +0000
62+++ pocketlint/tests/test_python.py 2011-04-17 16:27:29 +0000
63@@ -71,11 +71,14 @@
64 self.assertTrue('pocketlint/contrib/' in messages.__file__)
65
66 def test_code_without_issues(self):
67+ self.reporter.call_count = 0
68 checker = PythonChecker('bogus', good_python, self.reporter)
69 checker.check_flakes()
70 self.assertEqual([], self.reporter.messages)
71+ self.assertEqual(0, self.reporter.call_count)
72
73 def test_code_with_SyntaxError(self):
74+ self.reporter.call_count = 0
75 checker = PythonChecker(
76 'bogus', bad_syntax_python, self.reporter)
77 checker.check_flakes()
78@@ -83,6 +86,7 @@
79 0, 'Could not compile; non-default argument follows '
80 'default argument: ')]
81 self.assertEqual(expected, self.reporter.messages)
82+ self.assertEqual(1, self.reporter.call_count)
83
84 def test_code_with_very_bad_SyntaxError(self):
85 checker = PythonChecker(
86@@ -102,12 +106,14 @@
87 self.assertEqual(expected, self.reporter.messages)
88
89 def test_code_with_warnings(self):
90+ self.reporter.call_count = 0
91 checker = PythonChecker('bogus', ugly_python, self.reporter)
92 checker.check_flakes()
93 self.assertEqual(
94 [(3, "undefined name 'b'"),
95 (3, "local variable 'a' is assigned to but never used")],
96 self.reporter.messages)
97+ self.assertEqual(2, self.reporter.call_count)
98
99
100 class TestPEP8(CheckerTestCase):

Subscribers

People subscribed via source and target branches

to all changes: