from unittest import TestCase class AreaStrategy: def calculate(self, x, y): if x > 0 and y > 0: return x * y if x < 0 or y < 0: raise ValueError('dfsdf') else: return 0 class TestAreaStrategy(TestCase): def setUp(self): self._width = 90 self._height = 144 self._strategy = AreaStrategy() def testCalculate(self): strat = self._strategy self.assertEqual(self._width * self._height, strat.calculate(self._width, self._height)) self.assertEqual(0, strat.calculate(self._width, 0)) self.assertRaises(ValueError, strat.calculate, -self._width, self._height) self.assertRaises(ValueError, strat.calculate, -self._width, 0) if __name__ == '__main__': import unittest unittest.main()
Нужно определить
ASSERTION -?
TESTS -?
ERRORS-?
FAILURIES-?
Запустил код, получил следующее
Ran 1 test in 0.001s OK Traceback (most recent call last): unittest.main() File "C:\Python33\lib\unittest\main.py", line 125, in __init__ self.runTests() File "C:\Python33\lib\unittest\main.py", line 263, in runTests sys.exit(not self.result.wasSuccessful()) SystemExit: False
Видимо TEST 1, ERRORS 1, сколько ASSERTION и FAILURIES понятия не имею