File: test_tgplugin.py

package info (click to toggle)
mako 1.0.6%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,556 kB
  • ctags: 1,495
  • sloc: python: 11,807; makefile: 167
file content (49 lines) | stat: -rw-r--r-- 1,509 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from mako.ext.turbogears import TGPlugin
from test.util import result_lines
from test import TemplateTest, template_base
from mako import compat

tl = TGPlugin(options=dict(directories=[template_base]), extension='html')

class TestTGPlugin(TemplateTest):
    def test_basic(self):
        t = tl.load_template('/index.html')
        assert result_lines(t.render()) == [
            "this is index"
        ]
    def test_subdir(self):
        t = tl.load_template('/subdir/index.html')
        assert result_lines(t.render()) == [
            "this is sub index",
            "this is include 2"

        ]

        assert tl.load_template('/subdir/index.html').module_id == '_subdir_index_html'

    def test_basic_dot(self):
        t = tl.load_template('index')
        assert result_lines(t.render()) == [
            "this is index"
        ]
    def test_subdir_dot(self):
        t = tl.load_template('subdir.index')
        assert result_lines(t.render()) == [
            "this is sub index",
            "this is include 2"

        ]

        assert tl.load_template('subdir.index').module_id == '_subdir_index_html'

    def test_string(self):
        t = tl.load_template('foo', "hello world")
        assert t.render() == "hello world"

    def test_render(self):
        assert result_lines(tl.render({}, template='/index.html')) == [
            "this is index"
        ]
        assert result_lines(tl.render({}, template=compat.u('/index.html'))) == [
            "this is index"
        ]