Creating our first simple test

Testing is one of the pillars of any software during development, and later during maintenance and expansion too. Especially in the case of web applications where the application will handle high traffic and be scrutinized by a large number of end users at all times, testing becomes pretty important, as the user feedback determines the fate of the application. In this recipe, we will see how to start with test writing and also see more complex tests in the recipes to follow.

Getting ready

We will start with the creation of a new test file named app_tests.py at the root application level, that is, alongside the my_app folder.

The unittest2 Python library also needs to be installed using the following command:

$ pip install ...

Get Flask Framework Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.