Creating Some Tests: Running Tests
Explore how to create and run tests for your Flask API application, using functions to simulate user interactions and multiple test executions. Understand the role of assertions in testing and learn how to manage them for effective debugging and production readiness.
We'll cover the following...
Next, we’ll create a function that puts the API through its paces to play a game. To do this, we’ll need to create some random strings to enter the username, a task we enable with the random_string function.
Testing the game one time
The test functions can then be tested using the flask shell. Here’s an example of what that might look like, starting in the langman directory.
This example shows us that we can interactively use the application with the flask shell command where the FLASK_APP environment variable has been specified. However, within that shell, we can’t simply run the tests. Instead, we’ll have ...