NameError: name ‘time‘ is not defined
引入Import time这个包即可
import unittest
import time
class TestDemo(unittest.TestCase):
@classmethod
def setUp(self) -> None:
print("每一个测试用例之前会自动执行")
@classmethod
def tearDown(self) -> None:
print("====每一个测试用例执行之后都会自动执行一次====")
@classmethod
def setUpClass(cls) -> None:
print("测试类执行开始的时候执行一次")
@classmethod
def tearDownClass(cls) -> None:
print("测试类执行完成后,只执行一次")
time.sleep(2)
def test_01(self):
print("test_01")
time.sleep(2)
def test_02(self):
print("test_02")
time.sleep(3)
def test_03(self):
print("test_03")
def test_04(self):
print("test_04")
def test_05(self):
print("test_05")
if __name__ == "__main__":
unittest.main()
学而不思则罔,思而不学则殆