class TestTriangle: def setup(self): self.t1 = Triangle(12, 12) self.t2 = Triangle(10, 12) self.t3 = Triangle(12, 13) self.t4 = Triangle(10, 12) def test_area(self): assert self.t1.area() == 72 assert self.t2.area() == 60 assert self.t3.area() == 78 def test_str(self): assert str(self.t1) == "Triangle with base 12.0 and height 12.0" assert str(self.t2) == "Triangle with base 10.0 and height 12.0" assert str(self.t3) == "Triangle with base 12.0 and height 13.0" def test_eq(self): assert (self.t1 == self.t2) is False assert (self.t2 == self.t3) is False assert (self.t2 == self.t4) is True
class TestTriangle(): def setup(self): self.t1 = Triangle(3, 6) self.t2 = Triangle(2, 6) self.t3 = Triangle(5, 3) self.t4 = Triangle(7, 2) self.t5 = Triangle(2, 6) def test_area(self): assert self.t1.area() == 9 assert self.t2.area() == 6 assert self.t3.area() == 7.5 assert self.t4.area() == 7 def test_str(self): assert str(self.t1) == 'Triangle with base 3.0 and height 6.0' assert str(self.t3) == 'Triangle with base 5.0 and height 3.0' def test_eq(self): assert (self.t1 == self.t2) is False assert (self.t2 == self.t5) is True assert (self.t3 == self.t4) is False