Creating Some Tests: Additional Functions

Get to know some necessary functions we need for testing the game.

To create a test, we can exercise the method in the previous lesson repeatedly to see if the assertion ever fails. We do this by creating a new file called api_test.py and placing it in the langman directory.

Application fixture

In this file, we begin by constructing an application fixture. This allows us to work with the application. Ideally, the application creation would see from its configuration that the TESTING key has the value True, thereby connecting it to a testing database. This is general, as different configuration options can be tested in this way. Here, we use the existing database and tidy up after we’re done. Here’s the creation of the fixture.

Get hands-on with 1200+ tech skills courses.