Coverage for test_triangles.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-30 05:17 -0400

1"""Test the triangles module. 

2 

3Name: YOUR NAME 

4Date: THE DATE 

5""" 

6 

7from pytest import approx, raises 

8from triangles import valid, area, classify 

9 

10 

11def test_valid(): 

12 # NOTE: You should never type "== True". 

13 assert valid((3, 4, 5)) 

14 # NOTE: You should never type "== False". 

15 assert not valid((3, 4, 10)) 

16 

17 

18def test_area(): 

19 # NOTE: Use approx() to avoid floating-point errors. 

20 assert area((3, 4, 5)) == approx(6.0) 

21 # NOTE: Use raises() to check if errors are raised. 

22 with raises(ValueError): 

23 area((3, 4, 10)) 

24 

25 

26def test_classify(): 

27 assert classify((3, 4, 5)) == "Scalene"