import unittestclass TestunittestTestCase def test1self print1 def test2self print2 def test3self print3if __name__ == __main__ # 创建套件 suit = unittestTestSuite #
The code provided creates a test suite and adds a single test case to it. The test case is an instance of the Test class and calls the test2 method. Finally, the test suite is executed using the TextTestRunner class.
The output of this code will be:
2
This means that only the test2 method will be executed and print the number 2.
原文地址: https://www.cveoy.top/t/topic/h6hO 著作权归作者所有。请勿转载和采集!