Вот код:
import unittest import math p = math.pi class calc: def ball(self, rad): return 4 / 3 * p * (rad ** 3) def cube(self, rad): return rad ** 3 def cyl(self, rad, hig): return p * (rad ** 2) + p * rad * (math.sqrt(rad ** 2 + hig ** 2)) def cone(self, rad, hig): return 2 * p * (rad ** 2) + 2 * p * hig class test_calc(unittest.TestCase): def setup(self): self.calc = calc() def test_ball(self): self.assertEqual(self.calc.ball(1), 4.1887902047863905) def test_cube(self): self.assertEqual(self.calc.cube(4), 64) def test_cyl(self): self.assertEqual(self.calc.cyl(10, 2), 634.5401102472612) def test_cone(self): self.assertEqual(self.calc.cone(23, 5), 3355.220954033899) if __name__ == "__main__": unittest.main()
Использую Pycharm 2022, интепретатор - 3.7. Заранее спасибо за помощь