| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_start(): | 161 def test_parse_start(): |
| 162 # Header-line lines are headers. | 162 # Header-line lines are headers. |
| 163 assert parse_line('[Adblock Plus 1.1]', 'start').type == 'header' | 163 assert parse_line('[Adblock Plus 1.1]', 'start').type == 'header' |
| 164 # Even if they have extra characters around. | 164 # Even if they have extra characters around. |
| 165 assert parse_line('foo[Adblock Plus 1.1] bar', 'start').type == 'header' | 165 assert parse_line('foo[Adblock Plus 1.1] bar', 'start').type == 'header' |
| 166 | 166 |
| 167 with pytest.raises(ParseError): | 167 # But the inside of the header needs to be right. |
| 168 # But the inside of the header needs to be right. | 168 assert parse_line('[Adblock Minus 1.1]', 'start').type == 'filter' |
| 169 parse_line('[Adblock Minus 1.1]', 'start').type | 169 # Really right! |
| 170 | 170 assert parse_line('[Adblock 1.1]', 'start').type == 'filter' |
| 171 with pytest.raises(ParseError): | 171 # Otherwise it's just considered a filter. |
| 172 # Really right! | |
| 173 parse_line('[Adblock 1.1]', 'start') | |
| 174 | 172 |
| 175 # Metadata-like lines are metadata. | 173 # Metadata-like lines are metadata. |
| 176 assert parse_line('! Foo: bar', 'metadata').type == 'metadata' | 174 assert parse_line('! Foo: bar', 'metadata').type == 'metadata' |
| 177 | 175 |
| 178 | 176 |
| 179 def test_parse_metadata(): | 177 def test_parse_metadata(): |
| 180 # Header-like lines are just filters. | 178 # Header-like lines are just filters. |
| 181 assert parse_line('[Adblock 1.1]', 'metadata').type == 'filter' | 179 assert parse_line('[Adblock 1.1]', 'metadata').type == 'filter' |
| 182 # Metadata-like lines are metadata. | 180 # Metadata-like lines are metadata. |
| 183 assert parse_line('! Foo: bar', 'metadata').type == 'metadata' | 181 assert parse_line('! Foo: bar', 'metadata').type == 'metadata' |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 def test_exception_timing(): | 218 def test_exception_timing(): |
| 221 result = parse_filterlist(['! good line', '%bad line%']) | 219 result = parse_filterlist(['! good line', '%bad line%']) |
| 222 assert next(result) == Comment('good line') | 220 assert next(result) == Comment('good line') |
| 223 with pytest.raises(ParseError): | 221 with pytest.raises(ParseError): |
| 224 next(result) | 222 next(result) |
| 225 | 223 |
| 226 | 224 |
| 227 def test_parse_line_bytes(): | 225 def test_parse_line_bytes(): |
| 228 line = parse_line(b'! \xc3\xbc') | 226 line = parse_line(b'! \xc3\xbc') |
| 229 assert line.text == '\xfc' | 227 assert line.text == '\xfc' |
| OLD | NEW |