The simplest unittest module can be obtained via the TestCase subclass, to which the appropriate methods must be rewritten or added.
A simple unittest module can be composed as follows:
import unittest
class SimpleUnitTest(unittest.TestCase):
def test(self):
self.assertTrue(True)
if __name__ == '__main__':
unittest.main()
To run the unittest module, you need to include unittest.main (), while we have a single method, test(), which fails if True is ever False.
By executing the preceding example, you get the following result:
-----------------------------------------------------------
Ran 1 test in 0.005s
OK
The test was successful, thus giving the result, OK.
In the following section, we go into more detail about how the unittest module works. In particular, we want to study what the possible outcomes of a unit test are.