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

Side by Side Diff: tests/test_parser.py

Issue 29845767: Issue 6685 - Offer incremental filter list downloads (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Patch Set: Address comments on PS7 Created Aug. 30, 2018, 4:23 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
« no previous file with comments | « 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 assert line.text == 'Block foo' 147 assert line.text == 'Block foo'
148 148
149 149
150 def test_parse_meta(): 150 def test_parse_meta():
151 line = parse_line('! Homepage : http://aaa.com/b') 151 line = parse_line('! Homepage : http://aaa.com/b')
152 assert line.type == 'metadata' 152 assert line.type == 'metadata'
153 assert line.key == 'Homepage' 153 assert line.key == 'Homepage'
154 assert line.value == 'http://aaa.com/b' 154 assert line.value == 'http://aaa.com/b'
155 155
156 156
157 def test_parse_nonmeta():
158 line = parse_line('! WrongHeader: something')
159 assert line.type == 'comment'
160
161
162 def test_parse_instruction(): 157 def test_parse_instruction():
163 line = parse_line('%include foo:bar/baz.txt%') 158 line = parse_line('%include foo:bar/baz.txt%')
164 assert line.type == 'include' 159 assert line.type == 'include'
165 assert line.target == 'foo:bar/baz.txt' 160 assert line.target == 'foo:bar/baz.txt'
166 161
167 162
168 def test_parse_bad_instruction(): 163 def test_parse_bad_instruction():
169 with pytest.raises(ParseError): 164 with pytest.raises(ParseError):
170 parse_line('%foo bar%') 165 parse_line('%foo bar%')
171 166
(...skipping 17 matching lines...) Expand all
189 def test_exception_timing(): 184 def test_exception_timing():
190 result = parse_filterlist(['! good line', '%bad line%']) 185 result = parse_filterlist(['! good line', '%bad line%'])
191 assert next(result) == Comment('good line') 186 assert next(result) == Comment('good line')
192 with pytest.raises(ParseError): 187 with pytest.raises(ParseError):
193 next(result) 188 next(result)
194 189
195 190
196 def test_parse_line_bytes(): 191 def test_parse_line_bytes():
197 line = parse_line(b'! \xc3\xbc') 192 line = parse_line(b'! \xc3\xbc')
198 assert line.text == '\xfc' 193 assert line.text == '\xfc'
OLDNEW
« no previous file with comments | « tests/test_differ.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld