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

Side by Side Diff: tests/test_utils.py

Issue 29398791: Issue 5044 - Support absolute paths for Jinja templates (Closed)
Patch Set: Address reviewer comments on patch set 1 Created March 30, 2017, 6:34 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
(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."""
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."""
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)
37
38 assert template.render({'value': 1}) == 'value = 1'
OLDNEW
« sitescripts/utils.py ('K') | « sitescripts/utils.py ('k') | tox.ini » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld