How do I persist changes made within the same object inheriting from TestCase in unitttest? I've referred to Persist variable changes between tests in unittest?. And the following codes works well.
from unittest import TestCase, main as unittest_main
class TestSimpleFoo(TestCase):
def setUp(self):
pass
def test_a(self):
TestSimpleFoo.foo = 'can'
def test_f(self):
self.assertEqual(TestSimpleFoo.foo, 'can')
if __name__ == '__main__':
unittest_main()
However, If I change the test name "test_a" to "test_u", the code will be failed. Anyone can tell how could this happen? thanks.
Aucun commentaire:
Enregistrer un commentaire