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

Side by Side Diff: tests/test_parser.py

Issue 29465720: Issue 4970 - Document the library API of python-abp (Closed)
Patch Set: Rebase to match the new master and retouche the docstrings. Created Oct. 24, 2017, 4:06 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
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 }, 95 },
96 '#?#:-abp-properties(|background-image: url(data:*))': { 96 '#?#:-abp-properties(|background-image: url(data:*))': {
97 'selector': { 97 'selector': {
98 'type': ST.XCSS, 98 'type': ST.XCSS,
99 'value': ':-abp-properties(|background-image: url(data:*))' 99 'value': ':-abp-properties(|background-image: url(data:*))'
100 }, 100 },
101 'options': [], 101 'options': [],
102 }, 102 },
103 }.items()) 103 }.items())
104 def test_parse_filters(filter_text, expected): 104 def test_parse_filters(filter_text, expected):
105 """Parametric test for filter parsing""" 105 """Parametric test for filter parsing."""
106 parsed = parse_line(filter_text) 106 parsed = parse_line(filter_text)
107 assert parsed.type == 'filter' 107 assert parsed.type == 'filter'
108 assert parsed.text == filter_text 108 assert parsed.text == filter_text
109 for attribute, expected_value in expected.items(): 109 for attribute, expected_value in expected.items():
110 assert getattr(parsed, attribute) == expected_value 110 assert getattr(parsed, attribute) == expected_value
111 111
112 112
113 def test_parse_comment(): 113 def test_parse_comment():
114 line = parse_line('! Block foo') 114 line = parse_line('! Block foo')
115 assert line.type == 'comment' 115 assert line.type == 'comment'
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 def test_parse_filterlist(): 153 def test_parse_filterlist():
154 result = parse_filterlist(['! foo', '! Title: bar']) 154 result = parse_filterlist(['! foo', '! Title: bar'])
155 assert list(result) == [Comment('foo'), Metadata('Title', 'bar')] 155 assert list(result) == [Comment('foo'), Metadata('Title', 'bar')]
156 156
157 157
158 def test_exception_timing(): 158 def test_exception_timing():
159 result = parse_filterlist(['! good line', '%bad line%']) 159 result = parse_filterlist(['! good line', '%bad line%'])
160 assert next(result) == Comment('good line') 160 assert next(result) == Comment('good line')
161 with pytest.raises(ParseError): 161 with pytest.raises(ParseError):
162 next(result) 162 next(result)
OLDNEW

Powered by Google App Engine
This is Rietveld