| OLD | NEW |
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 assert line.target == 'foo:bar/baz.txt' | 153 assert line.target == 'foo:bar/baz.txt' |
| 154 | 154 |
| 155 | 155 |
| 156 def test_parse_bad_instruction(): | 156 def test_parse_bad_instruction(): |
| 157 with pytest.raises(ParseError): | 157 with pytest.raises(ParseError): |
| 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 next(parse_filterlist(['[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 '! Homepage : http://aaa.com/b', | 168 '! Homepage : http://aaa.com/b', |
| 169 '||example.com^', | 169 '||example.com^', |
| 170 '! Checksum: OaopkIiiAl77sSHk/VAWDA', | 170 '! Checksum: OaopkIiiAl77sSHk/VAWDA', |
| 171 '! Note: bla bla']) | 171 '! Note: bla bla']) |
| 172 | 172 |
| 173 assert next(result) == Header('Adblock Plus 1.1') | 173 assert next(result) == Header('Adblock Plus 1.1') |
| 174 assert next(result) == Metadata('Homepage', 'http://aaa.com/b') | 174 assert next(result) == Metadata('Homepage', 'http://aaa.com/b') |
| 175 assert next(result).type == 'filter' | 175 assert next(result).type == 'filter' |
| 176 assert next(result) == Metadata('Checksum', 'OaopkIiiAl77sSHk/VAWDA') | 176 assert next(result) == Metadata('Checksum', 'OaopkIiiAl77sSHk/VAWDA') |
| 177 assert next(result).type == 'comment' | 177 assert next(result).type == 'comment' |
| 178 | 178 |
| 179 with pytest.raises(StopIteration): | 179 with pytest.raises(StopIteration): |
| 180 next(result) | 180 next(result) |
| 181 | 181 |
| 182 | 182 |
| 183 def test_exception_timing(): | 183 def test_exception_timing(): |
| 184 result = parse_filterlist(['! good line', '%bad line%']) | 184 result = parse_filterlist(['! good line', '%bad line%']) |
| 185 assert next(result) == Comment('good line') | 185 assert next(result) == Comment('good line') |
| 186 with pytest.raises(ParseError): | 186 with pytest.raises(ParseError): |
| 187 next(result) | 187 next(result) |
| 188 | 188 |
| 189 | 189 |
| 190 def test_parse_line_bytes(): | 190 def test_parse_line_bytes(): |
| 191 line = parse_line(b'! \xc3\xbc') | 191 line = parse_line(b'! \xc3\xbc') |
| 192 assert line.text == '\xfc' | 192 assert line.text == '\xfc' |
| OLD | NEW |