Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 # This file is part of the Adblock Plus web scripts, | |
2 # Copyright (C) 2006-2017 eyeo GmbH | |
3 # | |
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 | |
6 # published by the Free Software Foundation. | |
7 # | |
8 # Adblock Plus is distributed in the hope that it will be useful, | |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 # GNU General Public License for more details. | |
12 # | |
13 # You should have received a copy of the GNU General Public License | |
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
15 | |
16 import pytest | |
17 | |
18 from sitescripts.utils import get_template | |
19 | |
20 | |
21 def test_get_template_default_path(): | |
22 """Load template from inside sitescripts.""" | |
Jon Sonesen
2017/04/03 07:42:41
Perhaps the docstring here should include the addi
Vasily Kuznetsov
2017/04/03 08:59:25
Thanks for bringing this up. Maybe we should say s
Jon Sonesen
2017/04/03 09:03:23
Well I brought this up because you mentioned that
Sebastian Noack
2017/04/03 09:51:43
I'm used to add leading/trailing new lines to docs
Vasily Kuznetsov
2017/04/03 10:25:15
Hm. Are you sure? I don't think I would suggest th
Vasily Kuznetsov
2017/04/03 10:25:15
PEP257 recommends that the summary in multiline do
| |
23 template = get_template('__init__.py') | |
24 assert template.render({}).startswith('# This file') | |
25 | |
26 | |
27 @pytest.mark.parametrize('mode', ['relative', 'absolute']) | |
28 def test_get_template(tmpdir, mode): | |
29 """Load template using relative or absolute path.""" | |
Jon Sonesen
2017/04/03 07:42:41
Same here?
| |
30 template_path = tmpdir.join('template.tmpl') | |
31 template_path.write('value = {{ value }}') | |
32 | |
33 if mode == 'absolute': | |
34 template = get_template(template_path.strpath) | |
35 else: | |
36 template = get_template('template.tmpl', template_path=tmpdir.strpath) | |
Jon Sonesen
2017/04/03 07:42:41
Does this work as relative since you provide the n
Vasily Kuznetsov
2017/04/03 08:59:25
It's considered relative because the first argumen
Jon Sonesen
2017/04/03 09:03:23
I see, thanks
| |
37 | |
38 assert template.render({'value': 1}) == 'value = 1' | |
OLD | NEW |