Skip to content

Commit 9da1191

Browse files
committed
Update jinja globals with fixture
1 parent cffe053 commit 9da1191

File tree

1 file changed

+10
-49
lines changed

1 file changed

+10
-49
lines changed

tests/test_jinja_globals.py

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,15 @@
66
import aiohttp_jinja2
77

88

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")
1911
env = aiohttp_jinja2.get_env(app)
2012
assert isinstance(env, jinja2.Environment)
2113
assert env is aiohttp_jinja2.get_env(app)
2214

2315

2416
@asyncio.coroutine
25-
def test_url(test_client, loop):
17+
def test_url(app_with_template, test_client):
2618

2719
@aiohttp_jinja2.template('tmpl.jinja2')
2820
@asyncio.coroutine
@@ -33,15 +25,7 @@ def index(request):
3325
def other(request):
3426
return
3527

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')}}")
4529
app.router.add_route('GET', '/', index)
4630
app.router.add_route('GET', '/user/{name}', other, name='other')
4731
client = yield from test_client(app)
@@ -53,22 +37,14 @@ def other(request):
5337

5438

5539
@asyncio.coroutine
56-
def test_url_with_query(test_client, loop):
40+
def test_url_with_query(app_with_template, test_client):
5741

5842
@aiohttp_jinja2.template('tmpl.jinja2')
5943
@asyncio.coroutine
6044
def index(request):
6145
return {}
6246

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'})}}")
7248
app.router.add_get('/', index, name='index')
7349
client = yield from test_client(app)
7450

@@ -109,21 +85,14 @@ def other(request):
10985

11086

11187
@asyncio.coroutine
112-
def test_static(test_client, loop):
88+
def test_static(app_with_template, test_client):
11389

11490
@aiohttp_jinja2.template('tmpl.jinja2')
11591
@asyncio.coroutine
11692
def index(request):
11793
return {}
11894

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') }}")
12796

12897
app['static_root_url'] = '/static'
12998
app.router.add_route('GET', '/', index)
@@ -136,22 +105,14 @@ def index(request):
136105

137106

138107
@asyncio.coroutine
139-
def test_static_var_missing(test_client, loop):
108+
def test_static_var_missing(app_with_template, test_client):
140109

141110
@aiohttp_jinja2.template('tmpl.jinja2')
142111
@asyncio.coroutine
143112
def index(request):
144113
return {}
145114

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') }}")
155116
app.router.add_route('GET', '/', index)
156117
client = yield from test_client(app)
157118

0 commit comments

Comments
 (0)