在 python unittest 中,我尝试了解如果我更改测试方法中的变量,该变量是否会在其他测试方法中更改。或者是否为每个方法运行setUp和tearDown方法,以便为每个方法再次设置变量?
我是说
AsdfTestCase(unittest.TestCase):
def setUp(self):
self.dict = {
'str': 'asdf',
'int': 10
}
def tearDown(self):
del self.dict
def test_asdf_1(self):
self.dict['str'] = 'test string'
def test_asdf_2(self):
print(self.dict)
Run Code Online (Sandbox Code Playgroud)
所以我问哪个输出test_asdf_2()将打印 'asdf'或'test_string'