forked from gregmalcolm/python_koans
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabout_triangle_project2.py
More file actions
25 lines (19 loc) · 952 Bytes
/
about_triangle_project2.py
File metadata and controls
25 lines (19 loc) · 952 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
# You need to finish implementing triangle() in the file 'triangle.py'
from triangle import *
class AboutTriangleProject2(Koan):
# The first assignment did not talk about how to handle errors.
# Let's handle that part now.
def test_illegal_triangles_throw_exceptions(self):
# In the code below, each line calls the specfied method with the arguments passed to it.
# E.g. this line:
# self.assertRaises(TriangleError, triangle, 0, 0, 0)
# calls triangle(0, 0, 0)
# All sides should be greater than 0
self.assertRaises(TriangleError, triangle, 0, 0, 0)
self.assertRaises(TriangleError, triangle, 3, 4, -5)
# The sum of any two sides should be greater than the third one
self.assertRaises(TriangleError, triangle, 1, 1, 3)
self.assertRaises(TriangleError, triangle, 2, 5, 2)