标签:ddt pci regex awr 就会 message hid rom npe
‘TestResult‘, ‘TestCase‘, ‘TestSuite‘,‘TextTestRunner‘, ‘TestLoader‘ ‘FunctionTestCase‘, ‘main‘,‘defaultTestLoader‘, ‘SkipTest‘, ‘skip‘, ‘skipIf‘, ‘skipUnless‘,‘expectedFailure‘, ‘TextTestResult‘, ‘installHandler‘,‘registerResult‘, ‘removeResult‘, ‘removeHandler‘
from .result import TestResult from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf, skipUnless, expectedFailure) from .suite import BaseTestSuite, TestSuite from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames, findTestCases) from .main import TestProgram, main from .runner import TextTestRunner, TextTestResult from .signals import installHandler, registerResult, removeResult, removeHandler
‘addCleanup‘, ‘addTypeEqualityFunc‘, ‘assertAlmostEqual‘, ‘assertAlmostEquals‘, ‘assertCountEqual‘, ‘assertDictContainsSubset‘, ‘assertDictEqual‘, ‘assertEqual‘, ‘assertEquals‘, ‘assertFalse‘, ‘assertGreater‘, ‘assertGreaterEqual‘, ‘assertIn‘, ‘assertIs‘, ‘assertIsInstance‘, ‘assertIsNone‘, ‘assertIsNot‘, ‘assertIsNotNone‘, ‘assertLess‘, ‘assertLessEqual‘, ‘assertListEqual‘, ‘assertLogs‘, ‘assertMultiLineEqual‘, ‘assertNotAlmostEqual‘, ‘assertNotAlmostEquals‘, ‘assertNotEqual‘, ‘assertNotEquals‘, ‘assertNotIn‘, ‘assertNotIsInstance‘, ‘assertNotRegex‘, ‘assertNotRegexpMatches‘, ‘assertRaises‘, ‘assertRaisesRegex‘, ‘assertRaisesRegexp‘, ‘assertRegex‘, ‘assertRegexpMatches‘, ‘assertSequenceEqual‘, ‘assertSetEqual‘, ‘assertTrue‘, ‘assertTupleEqual‘, ‘assertWarns‘, ‘assertWarnsRegex‘, ‘assert_‘, ‘countTestCases‘, ‘debug‘, ‘defaultTestResult‘, ‘doCleanups‘, ‘fail‘, ‘failIf‘, ‘failIfAlmostEqual‘, ‘failIfEqual‘, ‘failUnless‘, ‘failUnlessAlmostEqual‘, ‘failUnlessEqual‘, ‘failUnlessRaises‘, ‘failureException‘, ‘id‘, ‘longMessage‘, ‘maxDiff‘, ‘run‘, ‘setUp‘, ‘setUpClass‘, ‘shortDescription‘, ‘skipTest‘, ‘subTest‘, ‘tearDown‘, ‘tearDownClass‘
import unittest class unTest(unittest.TestCase): def setUp(cls): print("前置条件执行~\n") def tearDown(cls): print("后置条件执行~") def test_add(self): print(2+3) def test_minus(self): print(3-2) if __name__ == ‘__main__‘: unittest.main()
import unittest class unTest(unittest.TestCase): @classmethod def setUpClass(cls): print("setUpClass前置条件执行~\n") @classmethod def tearDownClass(cls): print("tearDownClass后置条件执行~") def test_add(self): print(2+3) def test_minus(self): print(3-2) if __name__ == ‘__main__‘: unittest.main()
import unittest class unTest(unittest.TestCase): @classmethod def setUpClass(cls): print("setUpClass前置条件执行~\n") @classmethod def tearDownClass(cls): print("tearDownClass后置条件执行~") def test_add(self): print(2+3) def test_minus(self): print(3-2) if __name__ == ‘__main__‘: unittest.main()
import unittest class unTest(unittest.TestCase): @classmethod def setUpClass(cls): print("setUpClass前置条件执行~\n") @classmethod def tearDownClass(cls): print("tearDownClass后置条件执行~") def test_add(self): print(2+3) def test_minus(self): print(3-2) suite=unittest.TestLoader().loadTestsFromTestCase(unTest) unittest.TextTestRunner(verbosity=2).run(suite)
import unittest from test01 import * suite=unittest.TestSuite(unittest.makeSuite(unTest02)) unittest.TextTestRunner(verbosity=2).run(suite)
import unittest from test01 import * suite=unittest.TestSuite() suite.addTest(unTest("test_add")) suite.addTest(unTest("test_minus")) suite.addTest(unTest02("test_multi")) unittest.TextTestRunner(verbosity=2).run(suite)
import unittest class unTest(unittest.TestCase): @classmethod def setUpClass(cls): print("setUpClass前置条件执行~\n") @classmethod def tearDownClass(cls): print("tearDownClass后置条件执行~") def test_add(self): print(2+3) def test_minus(self): print(3-2) #通过类加载,把unTest下面所有的方法都添加到suite中 suite=unittest.TestLoader().loadTestsFromTestCase(unTest) unittest.TextTestRunner(verbosity=2).run(suite)
import unittest class unTest(unittest.TestCase): @classmethod def setUpClass(cls): print("setUpClass前置条件执行~\n") @classmethod def tearDownClass(cls): print("tearDownClass后置条件执行~") def test_add(self): print(2+3) def test_minus(self): print(3-2) class unTest02(unittest.TestCase): def test_multi(self): print(2 * 3)
import unittest import test01#导入模块一:test01 suite=unittest.TestLoader().loadTestsFromModule(test01) unittest.TextTestRunner(verbosity=2).run(suite)
import unittest suite=unittest.TestLoader().loadTestsFromName(‘test01.unTest.test_minus‘) unittest.TextTestRunner(verbosity=2).run(suite)
import unittest import test01 suite=unittest.TestLoader().loadTestsFromName(‘unTest.test_minus‘,test01) #suite=unittest.TestLoader().loadTestsFromName(‘unTest.test_minus‘,module=test01) unittest.TextTestRunner(verbosity=2).run(suite)
import unittest import test01 suite=unittest.TestLoader().loadTestsFromNames([‘unTest.test_minus‘,‘unTest.test_add‘],test01) unittest.TextTestRunner(verbosity=2).run(suite)
unittest.TextTestRunner().run(suite)
import unittest import test01 suite=unittest.TestLoader().loadTestsFromModule(test01) filename=r"F:\reports\test.txt" file=open(filename,‘a‘) runner=unittest.TextTestRunner( stream=file, descriptions=True, verbosity=2 ) runner.run(suite)
filename=“F:\\reports\re.html"
file=open(filename,"wb")
runner = HTMLTestRunner.HTMLTestRunner( stream=file, title="测试标题", description="报告中的文字描述" )
runner.run(suite)
import unittest import test01 import HTMLTestReportCN suite=unittest.TestLoader().loadTestsFromModule(test01) filename=r"F:\reports\test.html" file=open(filename,‘wb‘) runner=HTMLTestReportCN.HTMLTestRunner( stream=file, title="html测试报告", tester="joba", verbosity=2 ) runner.run(suite)
标签:ddt pci regex awr 就会 message hid rom npe
原文地址:https://www.cnblogs.com/Qliupeng/p/11913219.html