@@ -9,30 +9,20 @@ class TestMain(unittest.TestCase):
9
9
10
10
def test_make_graph (self ):
11
11
'''Tests the make_graph function'''
12
- self .assertEqual (make_graph (0 ), "░░░░░░░░░░░░░░░░░░░░░░░░░" ,
13
- "0% should return ░░░░░░░░░░░░░░░░░░░░░░░░░" )
14
- self .assertEqual (make_graph (100 ), "█████████████████████████" ,
15
- "100% should return █████████████████████████" )
16
- self .assertEqual (make_graph (50 ), "████████████▒░░░░░░░░░░░░" ,
17
- "50% should return ████████████▒░░░░░░░░░░░░" )
18
- self .assertEqual (make_graph (50.001 ), "████████████▓░░░░░░░░░░░░" ,
19
- "50.001% should return ████████████▓░░░░░░░░░░░░" )
20
- self .assertEqual (make_graph (25 ), "██████▒░░░░░░░░░░░░░░░░░░" ,
21
- "25% should return ██████▒░░░░░░░░░░░░░░░░░░" )
22
- self .assertEqual (make_graph (75 ), "██████████████████▓░░░░░░" ,
23
- "75% should return ██████████████████▓░░░░░░" )
24
- self .assertEqual (make_graph (3.14 ), "▓░░░░░░░░░░░░░░░░░░░░░░░░" ,
25
- "3.14% should return ▓░░░░░░░░░░░░░░░░░░░░░░░░" )
26
- self .assertEqual (make_graph (9.901 ), "██▒░░░░░░░░░░░░░░░░░░░░░░" ,
27
- "9.901% should return ██▒░░░░░░░░░░░░░░░░░░░░░░" )
28
- self .assertEqual (make_graph (87.334 ), "██████████████████████░░░" ,
29
- "87.334% should return ██████████████████████░░░" )
30
- self .assertEqual (make_graph (87.333 ), "█████████████████████▓░░░" ,
31
- "87.333% should return █████████████████████▓░░░" )
32
- self .assertEqual (make_graph (4.666 ), "█░░░░░░░░░░░░░░░░░░░░░░░░" ,
33
- "4.666% should return █░░░░░░░░░░░░░░░░░░░░░░░░" )
34
- self .assertEqual (make_graph (4.667 ), "█▒░░░░░░░░░░░░░░░░░░░░░░░" ,
35
- "4.667% should return █▒░░░░░░░░░░░░░░░░░░░░░░░" )
12
+ def test (percent : float , result : str ):
13
+ self .assertEqual (make_graph (percent ), result , f"{ percent } % should return { result } " )
14
+ test (0 , "░░░░░░░░░░░░░░░░░░░░░░░░░" )
15
+ test (100 , "█████████████████████████" )
16
+ test (50 , "████████████▒░░░░░░░░░░░░" )
17
+ test (50.001 , "████████████▓░░░░░░░░░░░░" )
18
+ test (25 , "██████▒░░░░░░░░░░░░░░░░░░" )
19
+ test (75 , "██████████████████▓░░░░░░" )
20
+ test (3.14 , "▓░░░░░░░░░░░░░░░░░░░░░░░░" )
21
+ test (9.901 , "██▒░░░░░░░░░░░░░░░░░░░░░░" )
22
+ test (87.334 , "██████████████████████░░░" )
23
+ test (87.333 , "█████████████████████▓░░░" )
24
+ test (4.666 , "█░░░░░░░░░░░░░░░░░░░░░░░░" )
25
+ test (4.667 , "█▒░░░░░░░░░░░░░░░░░░░░░░░" )
36
26
37
27
38
28
if __name__ == '__main__' :
0 commit comments