Testing Tkinter code
Testing Tkinter code presents us with a few particular challenges. First, Tkinter handles many callbacks and methods asynchronously, meaning that we can't count on the results of some code to be apparent immediately. Also, testing GUI behaviors often relies on external factors such as window management or visual cues that our tests cannot detect.
In this section, we're going to learn some tools and strategies to address these issues and help you craft tests for your Tkinter code.
Managing asynchronous code
Whenever you interact with a Tkinter UI – whether it's clicking a button, typing in a field, or raising a window, for example – the response is not executed immediately in place.
Instead, these actions are placed in a sort of to-do list, called an event queue, to be handled later while code execution continues. While these actions seem instant to users, test code cannot count on a requested action being completed...