Python Unittest Inheritance -
i have 2 classes, , b.
class (unittest.testcase): #methods here class b (a): #methods here
when try , call self.assertequal(1,1) in method of class b, error mentioned here: why attributeerror python3.4's `unittest` library? yet if call in a, fine. unittest not follow regular inheritance? there specific way can use it?
i have tried example such:
import unittest class a(unittest.testcase): def test_a(self): self.assertequal(1, 1) class b(a): def test_b(self): self.assertequal(2, 3) if __name__ == '__main__': unittest.main()
and worked, test result:
test_a (__main__.a) ... ok test_a (__main__.b) ... ok test_b (__main__.b) ... fail
Comments
Post a Comment