-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTests.py
More file actions
33 lines (25 loc) · 865 Bytes
/
Copy pathTests.py
File metadata and controls
33 lines (25 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import unittest
from AreaCalculatorProject import Shape, Square, Rectangle
class TestShapes(unittest.TestCase):
def test_rectangle(self):
r = Rectangle(3, 4)
self.assertEqual(r.width, 3)
self.assertEqual(r.height, 4)
self.assertEqual(r.compute_area(), 12)
r.width = 5
self.assertEqual(r.width, 5)
self.assertEqual(r.height, 4)
self.assertEqual(r.compute_area(), 20)
r.height = 5
self.assertEqual(r.width, 5)
self.assertEqual(r.height, 5)
self.assertEqual(r.compute_area(), 25)
def test_square(self):
s = Square(3)
self.assertEqual(s.side, 3)
self.assertEqual(s.compute_area(), 9)
s.side = 5
self.assertEqual(s.side, 5)
self.assertEqual(s.compute_area(), 25)
if __name__ == '__main__':
unittest.main()