Writing unit tests for the application

It is time to write some unit tests for the application. We will make a new subclass of unittest.TestCase to hold all the unit tests.

Setting up a test package

As a first step, let's create a new package for holding the test cases. Create a new directory called test at the same level where you have the rest of the code. Next, create two new files inside this test directory, as shown here:

Setting up a test package

The test_wargame.py module is where new unit tests will be created. To recognize the directory as a Python package, add an empty __init__.py file.

Tip

If you haven't already, read Chapter 3, Modularize, Package, Deploy! for details ...

Get Learning Python Application Development 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.