June 2019
Beginner to intermediate
770 pages
19h 24m
English
It is often helpful to formally define a test suite. The unittest package is capable of discovering tests by default. When aggregating tests from multiple test modules, it's sometimes helpful to create a test suite in every test module. If each module defines a suite() function, we can replace test discovery with importing the suite() functions from each module. Also, if we customize TestRunner, we must use a suite. We can execute our tests as follows:
def suite2() -> unittest.TestSuite: s = unittest.TestSuite() load_from = unittest.defaultTestLoader.loadTestsFromTestCase s.addTests(load_from(TestCard)) s.addTests(load_from(TestAceCard)) s.addTests(load_from(TestFaceCard)) return s
We build a suite from our three TestCase ...
Read now
Unlock full access