How to do it...

In order to use Python's built-in unit testing framework, we have to import the Python unittest module. Let's create a new module and name it UnitTests.py.

We first import the unittest module, then we create our own class and, within this class, we inherit and extend the unittest.TestCase class.

The simplest code to do it looks as follows:

import unittest class GuiUnitTests(unittest.TestCase):     pass if __name__ == '__main__':     unittest.main()

The code isn't doing much yet, but when we run it, we do not get any errors, which is a good sign:

UnitTestsMinimum.py

We actually do get an output written to the console stating that ...

Get Python GUI Programming Cookbook - Second Edition 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.