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

Fixtures

Rather than perform the tedious task of creating the MyCalc objects in every test, our TestCase object can have a setUp() method that automatically creates any resources our tests need.

For example, take a look at the following code:

    def setUp(self):        self.mycalc1_0 = mycalc.MyCalc(1, 0)        self.mycalc36_12 = mycalc.MyCalc(36, 12)

Now, every test case can use these objects to run its tests. The setUp() method will be rerun before every test, so these objects will always be reset between test methods. If we have items that need to cleaned up after each test, we can define a tearDown() method, which will be run after each test (in this case, it's not necessary).

Now, for example, our test_add() method can be much simpler:

 def test_add(self): ...
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