11import pytest
22from ..exercises .exercise_64 import divide
33from ..exercises .exercise_65 import check_positive , NegativeValueError
4-
5- # from ..exercises.exercise_66 import
6- # from ..exercises.exercise_67 import
4+ from ..exercises .exercise_66 import ProductSalesCalculator , InvalidQuantityError
5+ from ..exercises .exercise_67 import process_strings
76
87
98def test_e64 ():
@@ -21,3 +20,33 @@ def test_e65():
2120 check_positive (- 1 )
2221 with pytest .raises (NegativeValueError ):
2322 check_positive (- 10 )
23+
24+
25+ def test_e66 ():
26+ with pytest .raises (InvalidQuantityError ):
27+ ProductSalesCalculator (10 , 0 )
28+ with pytest .raises (InvalidQuantityError ):
29+ ProductSalesCalculator (10 , - 1 )
30+
31+ psc = ProductSalesCalculator (10 , 1 )
32+ assert psc .calculate_total () == 10
33+ psc = ProductSalesCalculator (10 , 2 )
34+ assert psc .calculate_total () == 20
35+
36+
37+ def test_e67 ():
38+ test_strings = ["123" , "" , "abc" , "456" , "789" , "" ]
39+
40+ with pytest .raises (ExceptionGroup ) as exc_info :
41+ process_strings (test_strings )
42+
43+ exceptions = exc_info .value .exceptions
44+ assert len (exceptions ) == 3
45+
46+ value_error_raised = any (isinstance (e , ValueError ) for e in exceptions )
47+ assert value_error_raised , "ValueError was not raised as expected"
48+
49+ index_error_count = sum (isinstance (e , IndexError ) for e in exceptions )
50+ assert (
51+ index_error_count == 2
52+ ), "IndexError was not raised the correct number of times"
0 commit comments