Skip to Content
Python GUI Programming with Tkinter
book

Python GUI Programming with Tkinter

by Alan D. Moore
May 2018
Beginner to intermediate content levelBeginner to intermediate
452 pages
11h 26m
English
Packt Publishing
Content preview from Python GUI Programming with Tkinter

Testing our widgets

So far, we've done well with patch, Mock, and the default TestCase, but testing our widgets module is going to present some new challenges. To begin with, our widgets will need a Tk instance to be their root window. We can create this in each case's setUp() method, but this will slow down the tests considerably, and it isn't really necessary; our tests aren't going to modify the root window, so one root window will suffice for each test case. We can take advantage of the setUpClass() method to create a single instance of Tk just once at class instantiation. Secondly, we have a large number of widgets to test, which means we have a large number of test cases requiring the same boilerplate Tk() setup and tear down. 

To address ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python GUI Programming with Tkinter - Second Edition

Python GUI Programming with Tkinter - Second Edition

Alan D. Moore

Publisher Resources

ISBN: 9781788835886Supplemental Content