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
1=== modified file 'pocketlint/contrib/cssccc.py'
2--- pocketlint/contrib/cssccc.py 2011-04-18 01:43:03 +0000
3+++ pocketlint/contrib/cssccc.py 2011-05-10 20:12:57 +0000
4@@ -44,7 +44,7 @@
5 '''
6 from __future__ import with_statement
7
8-__version__ = '0.1.0'
9+__version__ = '0.1.1'
10
11 import sys
12
13@@ -380,11 +380,10 @@
14 break
15
16 # Look for comment start/end.
17- comment_check = _check_comment(data)
18 (comment_update,
19 before_comment,
20 after_comment,
21- newline_consumed) = comment_check
22+ newline_consumed) = _check_comment(data)
23 if comment_update is not None:
24 comment_started = comment_update
25
26@@ -438,15 +437,19 @@
27 before_comment = None
28 after_comment = None
29 newline_consumed = False
30+
31 comment_start = data.find(COMMENT_START)
32 if comment_start != -1:
33 comment_started = True
34 before_comment = data[:comment_start]
35+ # Only use `None` to signal that there is no text before the comment.
36+ if before_comment == '':
37+ before_comment = None
38
39 comment_end = data.find(COMMENT_END)
40 if comment_end != -1:
41 comment_started = False
42- # Comment end after the lenght of the actual comment end
43+ # Set comment end after the lenght of the actual comment end
44 # marker.
45 comment_end += len(COMMENT_END)
46 if before_comment is None and data[comment_end] == '\n':
47
48=== modified file 'pocketlint/tests/test_cssccc.py'
49--- pocketlint/tests/test_cssccc.py 2011-04-18 01:43:03 +0000
50+++ pocketlint/tests/test_cssccc.py 2011-05-10 20:12:57 +0000
51@@ -90,7 +90,7 @@
52 self.assertEqual(1, rule.declarations.start_character)
53
54 def test_getNextRule_stop(self):
55- text ='rule1{st1\n}\n@font-face {\n src: url("u\n u"); \n }\nr2{st2}'
56+ text = 'rule1{st1\n}\n@font-face {\n src: url("u\n u"); \n }\nr2{st2}'
57 lint = CSSCodingConventionChecker(text)
58 rule = lint.getNextRule()
59 self.assertTrue(rule.type is CSSRuleSet.type)
60@@ -100,21 +100,64 @@
61 self.assertTrue(rule.type is CSSRuleSet.type)
62 self.failUnlessRaises(StopIteration, lint.getNextRule)
63
64- def test_getNextRule_comment(self):
65- text = '\n\n/* c\nm*/\nsel\n{\ns/*com*/\ncont1;/*com*/\ncont2;}'
66- lint = CSSCodingConventionChecker(text)
67- rule = lint.getNextRule()
68- self.assertTrue(rule.type is CSSRuleSet.type)
69- self.assertEqual('\n\nsel\n', rule.selector.text)
70- self.assertEqual(0, rule.selector.start_line)
71- self.assertEqual(0, rule.selector.start_character)
72- self.assertEqual('\ns\ncont1;\ncont2;', rule.declarations.text)
73- self.assertEqual(5, rule.declarations.start_line)
74- self.assertEqual(1, rule.declarations.start_character)
75+ def test_getNextRule_comment_multiline(self):
76+ text = (
77+ '\n'
78+ '\n'
79+ '/* multi line\n'
80+ ' * comment \n'
81+ ' */\n'
82+ 'selector {\n'
83+ 'cont2;\n'
84+ '}')
85+ lint = CSSCodingConventionChecker(text)
86+ rule = lint.getNextRule()
87+ self.assertTrue(rule.type is CSSRuleSet.type)
88+ self.assertEqual('\n\nselector ', rule.selector.text)
89+ self.assertEqual(0, rule.selector.start_line)
90+ self.assertEqual(0, rule.selector.start_character)
91+
92+ def test_getNextRule_comment_inline(self):
93+ text = (
94+ 'selector {\n'
95+ 'so/* inline comment*/me\n'
96+ '}\n')
97+ lint = CSSCodingConventionChecker(text)
98+ rule = lint.getNextRule()
99+ self.assertTrue(rule.type is CSSRuleSet.type)
100+ self.assertEqual('\nsome\n', rule.declarations.text)
101+ self.assertEqual(0, rule.declarations.start_line)
102+ self.assertEqual(10, rule.declarations.start_character)
103+
104+ def test_getNextRule_comment_end_of_line(self):
105+ text = (
106+ 'selector {\n'
107+ 'cont1; /*end of line comment*/\n'
108+ '}')
109+ lint = CSSCodingConventionChecker(text)
110+ rule = lint.getNextRule()
111+ self.assertTrue(rule.type is CSSRuleSet.type)
112+ self.assertEqual('\ncont1; \n', rule.declarations.text)
113+ self.assertEqual(0, rule.declarations.start_line)
114+ self.assertEqual(10, rule.declarations.start_character)
115+
116+ def test_getNextRule_comment_single_line(self):
117+ text = (
118+ '\n'
119+ '/* single line comment */\n'
120+ 'selector2 {\n'
121+ 'cont1;\n'
122+ '}')
123+ lint = CSSCodingConventionChecker(text)
124+ rule = lint.getNextRule()
125+ self.assertTrue(rule.type is CSSRuleSet.type)
126+ self.assertEqual('\nselector2 ', rule.selector.text)
127+ self.assertEqual(0, rule.selector.start_line)
128+ self.assertEqual(0, rule.selector.start_character)
129
130 def test_get_at_import_rule(self):
131 '''Test for @import url(/css/screen.css) screen, projection;'''
132- text ='rule1{st1\n}\n@import url(somet) print, soment ;rule2{st2}'
133+ text = 'rule1{st1\n}\n@import url(somet) print, soment ;rule2{st2}'
134 lint = CSSCodingConventionChecker(text)
135 rule = lint.getNextRule()
136 self.assertTrue(rule.type is CSSRuleSet.type)
137@@ -131,7 +174,7 @@
138
139 def test_get_at_charset_rule(self):
140 '''Test for @charset "ISO-8859-15";'''
141- text ='rule1{st1\n}\n@charset "utf" ;rule2{st2}'
142+ text = 'rule1{st1\n}\n@charset "utf" ;rule2{st2}'
143 lint = CSSCodingConventionChecker(text)
144 rule = lint.getNextRule()
145 self.assertTrue(rule.type is CSSRuleSet.type)
146@@ -148,7 +191,7 @@
147
148 def test_get_at_namespace_rule(self):
149 '''Test for @namespace foo "http://foo" ;'''
150- text ='rule1{st1\n}@namespace foo "http://foo" ;rule2{st2}'
151+ text = 'rule1{st1\n}@namespace foo "http://foo" ;rule2{st2}'
152 lint = CSSCodingConventionChecker(text)
153 rule = lint.getNextRule()
154 self.assertTrue(rule.type is CSSRuleSet.type)
155@@ -170,7 +213,7 @@
156 margin-left: 5cm; /* left pages only */
157 }
158 '''
159- text ='rule1{st1\n}\n@page :left {\n mar; /*com*/\n }\nrule2{st2}'
160+ text = 'rule1{st1\n}\n@page :left {\n mar; /*com*/\n }\nrule2{st2}'
161 lint = CSSCodingConventionChecker(text)
162 rule = lint.getNextRule()
163 self.assertTrue(rule.type is CSSRuleSet.type)
164@@ -194,7 +237,7 @@
165 /fonts/example");
166 }
167 '''
168- text ='rule1{st1\n}\n@font-face {\n src: url("u\n u"); \n }\nr2{st2}'
169+ text = 'rule1{st1\n}\n@font-face {\n src: url("u\n u"); \n }\nr2{st2}'
170 lint = CSSCodingConventionChecker(text)
171 rule = lint.getNextRule()
172 self.assertTrue(rule.type is CSSRuleSet.type)

Subscribers

People subscribed via source and target branches

to all changes: