unittest测试框架求助
本帖最后由 chen1182501 于 2020-11-19 15:13 编辑主代码如下,两次都是执行test_data目录里的测试用例,在等待的10秒中,修改测试用例的a参数(比如改成"22222"),但写到日志里的还是"11111",请问这是为啥tests = unittest.TestLoader().discover('test_data',pattern="*.py")
unittest.TextTestRunner(verbosity=2).run(tests)
time.sleep(10)
tests2 = unittest.TestLoader().discover('test_data',pattern="*.py")
unittest.TextTestRunner(verbosity=2).run(tests2)
测试用例
class test_mytest(unittest.TestCase):
def setUp(self) -> None:
self.timer = time.strftime("%y-%m-%d %H:%M:%S", time.localtime(time.time()))
self.a="11111"
def test_1_get_success(self):
with open("result/debug.log","a") as f:
f.write(str(self.timer)+"\n")
f.write(self.a+"\n")
f.close()
def tearDown(self) -> None:
pass
调试一下
页:
[1]