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

Proposed by Adi Roiban
Status: Merged
Approved by: Curtis Hovey
Approved revision: 385
Merged at revision: 385
Proposed branch: lp:~adiroiban/pocket-lint/bug-780723
Merge into: lp:pocket-lint
Diff against target: 172 lines (+67/-21)
2 files modified
pocketlint/contrib/cssccc.py (+7/-4)
pocketlint/tests/test_cssccc.py (+60/-17)
To merge this branch: bzr merge lp:~adiroiban/pocket-lint/bug-780723
Reviewer Review Type Date Requested Status
Curtis Hovey code Approve
Review via email: mp+60550@code.launchpad.net

Description of the change

I have split the main comment test into multiple tests.

The previous build was failing at 'test_getNextRule_comment_single_line' test.

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

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'pocketlint/contrib/cssccc.py'
--- pocketlint/contrib/cssccc.py 2011-04-18 01:43:03 +0000
+++ pocketlint/contrib/cssccc.py 2011-05-10 20:12:57 +0000
@@ -44,7 +44,7 @@
44'''44'''
45from __future__ import with_statement45from __future__ import with_statement
4646
47__version__ = '0.1.0'47__version__ = '0.1.1'
4848
49import sys49import sys
5050
@@ -380,11 +380,10 @@
380 break380 break
381381
382 # Look for comment start/end.382 # Look for comment start/end.
383 comment_check = _check_comment(data)
384 (comment_update,383 (comment_update,
385 before_comment,384 before_comment,
386 after_comment,385 after_comment,
387 newline_consumed) = comment_check386 newline_consumed) = _check_comment(data)
388 if comment_update is not None:387 if comment_update is not None:
389 comment_started = comment_update388 comment_started = comment_update
390389
@@ -438,15 +437,19 @@
438 before_comment = None437 before_comment = None
439 after_comment = None438 after_comment = None
440 newline_consumed = False439 newline_consumed = False
440
441 comment_start = data.find(COMMENT_START)441 comment_start = data.find(COMMENT_START)
442 if comment_start != -1:442 if comment_start != -1:
443 comment_started = True443 comment_started = True
444 before_comment = data[:comment_start]444 before_comment = data[:comment_start]
445 # Only use `None` to signal that there is no text before the comment.
446 if before_comment == '':
447 before_comment = None
445448
446 comment_end = data.find(COMMENT_END)449 comment_end = data.find(COMMENT_END)
447 if comment_end != -1:450 if comment_end != -1:
448 comment_started = False451 comment_started = False
449 # Comment end after the lenght of the actual comment end452 # Set comment end after the lenght of the actual comment end
450 # marker.453 # marker.
451 comment_end += len(COMMENT_END)454 comment_end += len(COMMENT_END)
452 if before_comment is None and data[comment_end] == '\n':455 if before_comment is None and data[comment_end] == '\n':
453456
=== modified file 'pocketlint/tests/test_cssccc.py'
--- pocketlint/tests/test_cssccc.py 2011-04-18 01:43:03 +0000
+++ pocketlint/tests/test_cssccc.py 2011-05-10 20:12:57 +0000
@@ -90,7 +90,7 @@
90 self.assertEqual(1, rule.declarations.start_character)90 self.assertEqual(1, rule.declarations.start_character)
9191
92 def test_getNextRule_stop(self):92 def test_getNextRule_stop(self):
93 text ='rule1{st1\n}\n@font-face {\n src: url("u\n u"); \n }\nr2{st2}'93 text = 'rule1{st1\n}\n@font-face {\n src: url("u\n u"); \n }\nr2{st2}'
94 lint = CSSCodingConventionChecker(text)94 lint = CSSCodingConventionChecker(text)
95 rule = lint.getNextRule()95 rule = lint.getNextRule()
96 self.assertTrue(rule.type is CSSRuleSet.type)96 self.assertTrue(rule.type is CSSRuleSet.type)
@@ -100,21 +100,64 @@
100 self.assertTrue(rule.type is CSSRuleSet.type)100 self.assertTrue(rule.type is CSSRuleSet.type)
101 self.failUnlessRaises(StopIteration, lint.getNextRule)101 self.failUnlessRaises(StopIteration, lint.getNextRule)
102102
103 def test_getNextRule_comment(self):103 def test_getNextRule_comment_multiline(self):
104 text = '\n\n/* c\nm*/\nsel\n{\ns/*com*/\ncont1;/*com*/\ncont2;}'104 text = (
105 lint = CSSCodingConventionChecker(text)105 '\n'
106 rule = lint.getNextRule()106 '\n'
107 self.assertTrue(rule.type is CSSRuleSet.type)107 '/* multi line\n'
108 self.assertEqual('\n\nsel\n', rule.selector.text)108 ' * comment \n'
109 self.assertEqual(0, rule.selector.start_line)109 ' */\n'
110 self.assertEqual(0, rule.selector.start_character)110 'selector {\n'
111 self.assertEqual('\ns\ncont1;\ncont2;', rule.declarations.text)111 'cont2;\n'
112 self.assertEqual(5, rule.declarations.start_line)112 '}')
113 self.assertEqual(1, rule.declarations.start_character)113 lint = CSSCodingConventionChecker(text)
114 rule = lint.getNextRule()
115 self.assertTrue(rule.type is CSSRuleSet.type)
116 self.assertEqual('\n\nselector ', rule.selector.text)
117 self.assertEqual(0, rule.selector.start_line)
118 self.assertEqual(0, rule.selector.start_character)
119
120 def test_getNextRule_comment_inline(self):
121 text = (
122 'selector {\n'
123 'so/* inline comment*/me\n'
124 '}\n')
125 lint = CSSCodingConventionChecker(text)
126 rule = lint.getNextRule()
127 self.assertTrue(rule.type is CSSRuleSet.type)
128 self.assertEqual('\nsome\n', rule.declarations.text)
129 self.assertEqual(0, rule.declarations.start_line)
130 self.assertEqual(10, rule.declarations.start_character)
131
132 def test_getNextRule_comment_end_of_line(self):
133 text = (
134 'selector {\n'
135 'cont1; /*end of line comment*/\n'
136 '}')
137 lint = CSSCodingConventionChecker(text)
138 rule = lint.getNextRule()
139 self.assertTrue(rule.type is CSSRuleSet.type)
140 self.assertEqual('\ncont1; \n', rule.declarations.text)
141 self.assertEqual(0, rule.declarations.start_line)
142 self.assertEqual(10, rule.declarations.start_character)
143
144 def test_getNextRule_comment_single_line(self):
145 text = (
146 '\n'
147 '/* single line comment */\n'
148 'selector2 {\n'
149 'cont1;\n'
150 '}')
151 lint = CSSCodingConventionChecker(text)
152 rule = lint.getNextRule()
153 self.assertTrue(rule.type is CSSRuleSet.type)
154 self.assertEqual('\nselector2 ', rule.selector.text)
155 self.assertEqual(0, rule.selector.start_line)
156 self.assertEqual(0, rule.selector.start_character)
114157
115 def test_get_at_import_rule(self):158 def test_get_at_import_rule(self):
116 '''Test for @import url(/css/screen.css) screen, projection;'''159 '''Test for @import url(/css/screen.css) screen, projection;'''
117 text ='rule1{st1\n}\n@import url(somet) print, soment ;rule2{st2}'160 text = 'rule1{st1\n}\n@import url(somet) print, soment ;rule2{st2}'
118 lint = CSSCodingConventionChecker(text)161 lint = CSSCodingConventionChecker(text)
119 rule = lint.getNextRule()162 rule = lint.getNextRule()
120 self.assertTrue(rule.type is CSSRuleSet.type)163 self.assertTrue(rule.type is CSSRuleSet.type)
@@ -131,7 +174,7 @@
131174
132 def test_get_at_charset_rule(self):175 def test_get_at_charset_rule(self):
133 '''Test for @charset "ISO-8859-15";'''176 '''Test for @charset "ISO-8859-15";'''
134 text ='rule1{st1\n}\n@charset "utf" ;rule2{st2}'177 text = 'rule1{st1\n}\n@charset "utf" ;rule2{st2}'
135 lint = CSSCodingConventionChecker(text)178 lint = CSSCodingConventionChecker(text)
136 rule = lint.getNextRule()179 rule = lint.getNextRule()
137 self.assertTrue(rule.type is CSSRuleSet.type)180 self.assertTrue(rule.type is CSSRuleSet.type)
@@ -148,7 +191,7 @@
148191
149 def test_get_at_namespace_rule(self):192 def test_get_at_namespace_rule(self):
150 '''Test for @namespace foo "http://foo" ;'''193 '''Test for @namespace foo "http://foo" ;'''
151 text ='rule1{st1\n}@namespace foo "http://foo" ;rule2{st2}'194 text = 'rule1{st1\n}@namespace foo "http://foo" ;rule2{st2}'
152 lint = CSSCodingConventionChecker(text)195 lint = CSSCodingConventionChecker(text)
153 rule = lint.getNextRule()196 rule = lint.getNextRule()
154 self.assertTrue(rule.type is CSSRuleSet.type)197 self.assertTrue(rule.type is CSSRuleSet.type)
@@ -170,7 +213,7 @@
170 margin-left: 5cm; /* left pages only */213 margin-left: 5cm; /* left pages only */
171 }214 }
172 '''215 '''
173 text ='rule1{st1\n}\n@page :left {\n mar; /*com*/\n }\nrule2{st2}'216 text = 'rule1{st1\n}\n@page :left {\n mar; /*com*/\n }\nrule2{st2}'
174 lint = CSSCodingConventionChecker(text)217 lint = CSSCodingConventionChecker(text)
175 rule = lint.getNextRule()218 rule = lint.getNextRule()
176 self.assertTrue(rule.type is CSSRuleSet.type)219 self.assertTrue(rule.type is CSSRuleSet.type)
@@ -194,7 +237,7 @@
194 /fonts/example");237 /fonts/example");
195 }238 }
196 '''239 '''
197 text ='rule1{st1\n}\n@font-face {\n src: url("u\n u"); \n }\nr2{st2}'240 text = 'rule1{st1\n}\n@font-face {\n src: url("u\n u"); \n }\nr2{st2}'
198 lint = CSSCodingConventionChecker(text)241 lint = CSSCodingConventionChecker(text)
199 rule = lint.getNextRule()242 rule = lint.getNextRule()
200 self.assertTrue(rule.type is CSSRuleSet.type)243 self.assertTrue(rule.type is CSSRuleSet.type)

Subscribers

People subscribed via source and target branches

to all changes: