Skip to content
Myr

test_js_example.py

This file

Path

examples/javascript/tests/test_js_example.py

28 lines · 712 bytes · Python

Last changed by

Merge pull request #2699 from pallets/javascriptDavid Lordbefore adoption746b91d

History of this file

Take it

1import pytest23from flask import template_rendered456@pytest.mark.parametrize(('path', 'template_name'), (7    ('/', 'plain.html'),8    ('/plain', 'plain.html'),9    ('/fetch', 'fetch.html'),10    ('/jquery', 'jquery.html'),11))12def test_index(app, client, path, template_name):13    def check(sender, template, context):14        assert template.name == template_name1516    with template_rendered.connected_to(check, app):17        client.get(path)181920@pytest.mark.parametrize(('a', 'b', 'result'), (21    (2, 3, 5),22    (2.5, 3, 5.5),23    (2, None, 2),24    (2, 'b', 2),25))26def test_add(client, a, b, result):27    response = client.post('/add', data={'a': a, 'b': b})28    assert response.get_json()['result'] == result