@@ -30,7 +30,7 @@ def func(request):
30
30
31
31
32
32
@asyncio .coroutine
33
- def test_render_class_based_view (loop , test_client ):
33
+ def test_render_class_based_view (app_with_template , test_client ):
34
34
class MyView (web .View ):
35
35
@aiohttp_jinja2 .template ('tmpl.jinja2' )
36
36
@asyncio .coroutine
@@ -39,11 +39,7 @@ def get(self):
39
39
40
40
template = '<html><body><h1>{{head}}</h1>{{text}}</body></html>'
41
41
42
- app = web .Application (loop = loop )
43
- aiohttp_jinja2 .setup (app , loader = jinja2 .DictLoader ({
44
- 'tmpl.jinja2' : template
45
- }))
46
-
42
+ app = app_with_template (template )
47
43
app .router .add_route ('*' , '/' , MyView )
48
44
49
45
client = yield from test_client (app )
@@ -56,7 +52,7 @@ def get(self):
56
52
57
53
58
54
@asyncio .coroutine
59
- def test_meth (loop , test_client ):
55
+ def test_meth (app_with_template , test_client ):
60
56
61
57
class Handler :
62
58
@@ -69,11 +65,7 @@ def meth(self, request):
69
65
70
66
handler = Handler ()
71
67
72
- app = web .Application (loop = loop )
73
- aiohttp_jinja2 .setup (app , loader = jinja2 .DictLoader ({
74
- 'tmpl.jinja2' : template
75
- }))
76
-
68
+ app = app_with_template (template )
77
69
app .router .add_route ('*' , '/' , handler .meth )
78
70
79
71
client = yield from test_client (app )
@@ -86,19 +78,15 @@ def meth(self, request):
86
78
87
79
88
80
@asyncio .coroutine
89
- def test_convert_func_to_coroutine (loop , test_client ):
81
+ def test_convert_func_to_coroutine (app_with_template , test_client ):
90
82
91
83
@aiohttp_jinja2 .template ('tmpl.jinja2' )
92
84
def func (request ):
93
85
return {'head' : 'HEAD' , 'text' : 'text' }
94
86
95
87
template = '<html><body><h1>{{head}}</h1>{{text}}</body></html>'
96
88
97
- app = web .Application (loop = loop )
98
- aiohttp_jinja2 .setup (app , loader = jinja2 .DictLoader ({
99
- 'tmpl.jinja2' : template
100
- }))
101
-
89
+ app = app_with_template (template )
102
90
app .router .add_route ('*' , '/' , func )
103
91
104
92
client = yield from test_client (app )
@@ -132,19 +120,15 @@ def func(request):
132
120
133
121
134
122
@asyncio .coroutine
135
- def test_set_status (loop , test_client ):
123
+ def test_set_status (app_with_template , test_client ):
136
124
137
125
@aiohttp_jinja2 .template ('tmpl.jinja2' , status = 201 )
138
126
def func (request ):
139
127
return {'head' : 'HEAD' , 'text' : 'text' }
140
128
141
129
template = '<html><body><h1>{{head}}</h1>{{text}}</body></html>'
142
130
143
- app = web .Application (loop = loop )
144
- aiohttp_jinja2 .setup (app , loader = jinja2 .DictLoader ({
145
- 'tmpl.jinja2' : template
146
- }))
147
-
131
+ app = app_with_template (template )
148
132
app .router .add_route ('*' , '/' , func )
149
133
150
134
client = yield from test_client (app )
@@ -157,7 +141,7 @@ def func(request):
157
141
158
142
159
143
@asyncio .coroutine
160
- def test_render_template (loop , test_client ):
144
+ def test_render_template (app_with_template , test_client ):
161
145
162
146
@asyncio .coroutine
163
147
def func (request ):
@@ -167,11 +151,7 @@ def func(request):
167
151
168
152
template = '<html><body><h1>{{head}}</h1>{{text}}</body></html>'
169
153
170
- app = web .Application (loop = loop )
171
- aiohttp_jinja2 .setup (app , loader = jinja2 .DictLoader ({
172
- 'tmpl.jinja2' : template
173
- }))
174
-
154
+ app = app_with_template (template )
175
155
app .router .add_route ('*' , '/' , func )
176
156
177
157
client = yield from test_client (app )
@@ -184,7 +164,7 @@ def func(request):
184
164
185
165
186
166
@asyncio .coroutine
187
- def test_render_template_custom_status (loop , test_client ):
167
+ def test_render_template_custom_status (app_with_template , test_client ):
188
168
189
169
@asyncio .coroutine
190
170
def func (request ):
@@ -194,11 +174,7 @@ def func(request):
194
174
195
175
template = '<html><body><h1>{{head}}</h1>{{text}}</body></html>'
196
176
197
- app = web .Application (loop = loop )
198
- aiohttp_jinja2 .setup (app , loader = jinja2 .DictLoader ({
199
- 'tmpl.jinja2' : template
200
- }))
201
-
177
+ app = app_with_template (template )
202
178
app .router .add_route ('*' , '/' , func )
203
179
204
180
client = yield from test_client (app )
@@ -233,17 +209,14 @@ def func(request):
233
209
234
210
235
211
@asyncio .coroutine
236
- def test_render_not_mapping (loop ):
212
+ def test_render_not_mapping (app_with_template ):
237
213
238
214
@aiohttp_jinja2 .template ('tmpl.jinja2' )
239
215
@asyncio .coroutine
240
216
def func (request ):
241
217
return 123
242
218
243
- app = web .Application (loop = loop )
244
- aiohttp_jinja2 .setup (app , loader = jinja2 .DictLoader (
245
- {'tmpl.jinja2' : 'tmpl' }))
246
-
219
+ app = app_with_template ("tmpl" )
247
220
app .router .add_route ('GET' , '/' , func )
248
221
249
222
req = make_mocked_request ('GET' , '/' , app = app )
@@ -255,17 +228,15 @@ def func(request):
255
228
256
229
257
230
@asyncio .coroutine
258
- def test_render_without_context (loop , test_client ):
231
+ def test_render_without_context (app_with_template , test_client ):
259
232
260
233
@aiohttp_jinja2 .template ('tmpl.jinja2' )
261
234
def func (request ):
262
235
pass
263
236
264
237
template = '<html><body><p>{{text}}</p></body></html>'
265
238
266
- app = web .Application (loop = loop )
267
- aiohttp_jinja2 .setup (app , loader = jinja2 .DictLoader (
268
- {'tmpl.jinja2' : template }))
239
+ app = app_with_template (template )
269
240
270
241
app .router .add_route ('GET' , '/' , func )
271
242
0 commit comments