Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Flask Jinja template - testing

import app

def test_app():
    web = app.app.test_client()

    rv = web.get('/')
    assert rv.status == '200 OK'
    assert b'<form action="/echo" method="POST">' in rv.data

    rv = web.post('/echo', data={'text': 'Hello'})
    assert rv.status == '200 OK'
    assert b'You said: Hello' == rv.data

    rv = web.post('/echo')
    assert rv.status == '200 OK'
    assert b'You said: ' == rv.data