Debian Codegraph @

tests/test_jinja_filters.py

raw symbols SCIP
1 import jinja2
2 from aiohttp import web
3
4 import aiohttp_jinja2
5
6
7 async def test_jinja_filters(aiohttp_client):
8 @aiohttp_jinja2.template("tmpl.jinja2")
9 async def index(request):
10 return {}
11
12 def add_2(value):
13 return value + 2
14
15 app = web.Application()
16 aiohttp_jinja2.setup(
17 app,
18 loader=jinja2.DictLoader({"tmpl.jinja2": "{{ 5|add_2 }}"}),
19 filters={"add_2": add_2},
20 )
21
22 app.router.add_route("GET", "/", index)
23 client = await aiohttp_client(app)
24
25 resp = await client.get("/")
26 assert 200 == resp.status
27 txt = await resp.text()
28 assert "7" == txt