6
6
import aiohttp_jinja2
7
7
8
8
9
- def test_get_env (loop ):
10
- app = web .Application (loop = loop )
11
- aiohttp_jinja2 .setup (
12
- app ,
13
- loader = jinja2 .DictLoader ({
14
- 'tmpl.jinja2' : "tmpl"
15
- }),
16
- enable_async = False ,
17
- )
18
-
9
+ def test_get_env (app_with_template ):
10
+ app = app_with_template ("tmpl" )
19
11
env = aiohttp_jinja2 .get_env (app )
20
12
assert isinstance (env , jinja2 .Environment )
21
13
assert env is aiohttp_jinja2 .get_env (app )
22
14
23
15
24
16
@asyncio .coroutine
25
- def test_url (test_client , loop ):
17
+ def test_url (app_with_template , test_client ):
26
18
27
19
@aiohttp_jinja2 .template ('tmpl.jinja2' )
28
20
@asyncio .coroutine
@@ -33,15 +25,7 @@ def index(request):
33
25
def other (request ):
34
26
return
35
27
36
- app = web .Application (loop = loop )
37
- aiohttp_jinja2 .setup (
38
- app ,
39
- loader = jinja2 .DictLoader ({
40
- 'tmpl.jinja2' : "{{ url('other', name='John_Doe')}}"
41
- }),
42
- enable_async = False ,
43
- )
44
-
28
+ app = app_with_template ("{{ url('other', name='John_Doe')}}" )
45
29
app .router .add_route ('GET' , '/' , index )
46
30
app .router .add_route ('GET' , '/user/{name}' , other , name = 'other' )
47
31
client = yield from test_client (app )
@@ -53,22 +37,14 @@ def other(request):
53
37
54
38
55
39
@asyncio .coroutine
56
- def test_url_with_query (test_client , loop ):
40
+ def test_url_with_query (app_with_template , test_client ):
57
41
58
42
@aiohttp_jinja2 .template ('tmpl.jinja2' )
59
43
@asyncio .coroutine
60
44
def index (request ):
61
45
return {}
62
46
63
- app = web .Application (loop = loop )
64
- aiohttp_jinja2 .setup (
65
- app ,
66
- loader = jinja2 .DictLoader ({
67
- 'tmpl.jinja2' : "{{ url('index', query_={'foo': 'bar'})}}"
68
- }),
69
- enable_async = False ,
70
- )
71
-
47
+ app = app_with_template ("{{ url('index', query_={'foo': 'bar'})}}" )
72
48
app .router .add_get ('/' , index , name = 'index' )
73
49
client = yield from test_client (app )
74
50
@@ -109,21 +85,14 @@ def other(request):
109
85
110
86
111
87
@asyncio .coroutine
112
- def test_static (test_client , loop ):
88
+ def test_static (app_with_template , test_client ):
113
89
114
90
@aiohttp_jinja2 .template ('tmpl.jinja2' )
115
91
@asyncio .coroutine
116
92
def index (request ):
117
93
return {}
118
94
119
- app = web .Application (loop = loop )
120
- aiohttp_jinja2 .setup (
121
- app ,
122
- loader = jinja2 .DictLoader ({
123
- 'tmpl.jinja2' : "{{ static('whatever.js') }}"
124
- }),
125
- enable_async = False ,
126
- )
95
+ app = app_with_template ("{{ static('whatever.js') }}" )
127
96
128
97
app ['static_root_url' ] = '/static'
129
98
app .router .add_route ('GET' , '/' , index )
@@ -136,22 +105,14 @@ def index(request):
136
105
137
106
138
107
@asyncio .coroutine
139
- def test_static_var_missing (test_client , loop ):
108
+ def test_static_var_missing (app_with_template , test_client ):
140
109
141
110
@aiohttp_jinja2 .template ('tmpl.jinja2' )
142
111
@asyncio .coroutine
143
112
def index (request ):
144
113
return {}
145
114
146
- app = web .Application (loop = loop )
147
- aiohttp_jinja2 .setup (
148
- app ,
149
- loader = jinja2 .DictLoader ({
150
- 'tmpl.jinja2' : "{{ static('whatever.js') }}"
151
- }),
152
- enable_async = False ,
153
- )
154
-
115
+ app = app_with_template ("{{ static('whatever.js') }}" )
155
116
app .router .add_route ('GET' , '/' , index )
156
117
client = yield from test_client (app )
157
118
0 commit comments