Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: tests/test_parser.py

Issue 29879650: Issue 6950 - Don't include headers and metadata from includes into output (Closed)
Patch Set: Simplify regexp Created Sept. 14, 2018, 2:35 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« abp/filters/renderer.py ('K') | « tests/test_differ.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 parse_line('%foo bar%') 158 parse_line('%foo bar%')
159 159
160 160
161 def test_parse_bad_header(): 161 def test_parse_bad_header():
162 with pytest.raises(ParseError): 162 with pytest.raises(ParseError):
163 parse_line('[Adblock 1.1]') 163 parse_line('[Adblock 1.1]')
164 164
165 165
166 def test_parse_filterlist(): 166 def test_parse_filterlist():
167 result = parse_filterlist(['[Adblock Plus 1.1]', 167 result = parse_filterlist(['[Adblock Plus 1.1]',
168 '! Last modified: 26 Jul 2018 02:10 UTC',
Vasily Kuznetsov 2018/09/14 15:09:35 Maybe we keep this and verify that it's parsed as
Sebastian Noack 2018/09/14 15:33:25 Done.
169 '! Homepage : http://aaa.com/b', 168 '! Homepage : http://aaa.com/b',
170 '||example.com^', 169 '||example.com^',
171 '! Checksum: OaopkIiiAl77sSHk/VAWDA', 170 '! Checksum: OaopkIiiAl77sSHk/VAWDA',
172 '! Note: bla bla']) 171 '! Note: bla bla'])
173 172
174 assert next(result) == Header('Adblock Plus 1.1') 173 assert next(result) == Header('Adblock Plus 1.1')
175 assert next(result).type == 'comment'
176 assert next(result) == Metadata('Homepage', 'http://aaa.com/b') 174 assert next(result) == Metadata('Homepage', 'http://aaa.com/b')
177 assert next(result).type == 'filter' 175 assert next(result).type == 'filter'
178 assert next(result) == Metadata('Checksum', 'OaopkIiiAl77sSHk/VAWDA') 176 assert next(result) == Metadata('Checksum', 'OaopkIiiAl77sSHk/VAWDA')
179 assert next(result).type == 'comment' 177 assert next(result).type == 'comment'
180 178
181 with pytest.raises(StopIteration): 179 with pytest.raises(StopIteration):
182 next(result) 180 next(result)
183 181
184 182
185 def test_exception_timing(): 183 def test_exception_timing():
186 result = parse_filterlist(['! good line', '%bad line%']) 184 result = parse_filterlist(['! good line', '%bad line%'])
187 assert next(result) == Comment('good line') 185 assert next(result) == Comment('good line')
188 with pytest.raises(ParseError): 186 with pytest.raises(ParseError):
189 next(result) 187 next(result)
190 188
191 189
192 def test_parse_line_bytes(): 190 def test_parse_line_bytes():
193 line = parse_line(b'! \xc3\xbc') 191 line = parse_line(b'! \xc3\xbc')
194 assert line.text == '\xfc' 192 assert line.text == '\xfc'
OLDNEW
« abp/filters/renderer.py ('K') | « tests/test_differ.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld