June 2019
Beginner to intermediate
770 pages
19h 24m
English
For proper unit testing, we want a more formal exchange between a client and a server. The Flask framework provides test_client(), which gives us the features required to make requests of a Flask server to be sure that the responses are correct. Once a test client object has been created, we can make our get, post, put, patch, and delete requests to confirm that a function behaves correctly.
The doctest module will locate Python examples inside document strings for a module or function. This makes it easy to include examples inside the definition of the relevant function. Here's an example of using the doctest features to test a Flask module:
@app.route("/openapi.json")def openapi() -> ...
Read now
Unlock full access