@@ -9,27 +9,45 @@ class TestCountTestCasesForProblem:
99 "json_data, expected" ,
1010 [
1111 (
12- {"test_methods" : [{"test_cases" : "[(1, 2, 3), (4, 5, 6)]" }, {"test_cases" : "[(7, 8)]" }]},
12+ {
13+ "test_methods" : [
14+ {"test_cases" : {"list" : ["(1, 2, 3)" , "(4, 5, 6)" ]}},
15+ {"test_cases" : {"list" : ["(7, 8)" ]}},
16+ ]
17+ },
1318 3 ,
1419 ),
1520 (
1621 {
1722 "_test_methods" : {
1823 "list" : [
19- {"test_cases" : "[ (1, 2), (3, 4), (5, 6)]" },
20- {"test_cases" : "[ (7, 8, 9)]" },
24+ {"test_cases" : { "list" : [ " (1, 2)" , " (3, 4)" , " (5, 6)" ]} },
25+ {"test_cases" : { "list" : [ " (7, 8, 9)" ]} },
2126 ]
2227 }
2328 },
2429 4 ,
2530 ),
26- ({"test_methods" : [{"test_cases" : "[]" }, {"test_cases" : "" }, {"test_cases" : " " }]}, 0 ),
31+ (
32+ {
33+ "test_methods" : [
34+ {"test_cases" : {"list" : []}},
35+ {"test_cases" : "" },
36+ {"test_cases" : " " },
37+ ]
38+ },
39+ 0 ,
40+ ),
2741 ({}, 0 ),
2842 (
2943 {
3044 "test_methods" : [
31- {"test_cases" : "[([1, 2], 'hello', True), ([3, 4], 'world', False)]" },
32- {"test_cases" : "[([], '', None)]" },
45+ {
46+ "test_cases" : {
47+ "list" : ["([1, 2], 'hello', True)" , "([3, 4], 'world', False)" ]
48+ }
49+ },
50+ {"test_cases" : {"list" : ["([], '', None)" ]}},
3351 ]
3452 },
3553 3 ,
@@ -39,16 +57,21 @@ class TestCountTestCasesForProblem:
3957 def test_count_test_cases (self , json_data , expected ):
4058 assert count_test_cases_for_problem (json_data ) == expected
4159
42- def test_invalid_test_cases_raises_error (self ):
60+ def test_invalid_test_cases_returns_zero (self ):
61+ """Test that invalid test cases are ignored and return 0."""
4362 json_data = {"test_methods" : [{"test_cases" : "invalid python literal" }]}
44- with pytest . raises (( ValueError , SyntaxError )):
45- count_test_cases_for_problem (json_data )
63+ # Current implementation ignores invalid test cases and returns 0
64+ assert count_test_cases_for_problem (json_data ) == 0
4665
4766 def test_python_expressions_in_test_cases (self ):
4867 """Test that Python expressions like 'string' * 100 are handled correctly."""
4968 json_data = {
5069 "test_methods" : [
51- {"test_cases" : "[('input', 'expected'), ('100[leetcode]', 'leetcode' * 100)]" }
70+ {
71+ "test_cases" : {
72+ "list" : ["('input', 'expected')" , "('100[leetcode]', 'leetcode' * 100)" ]
73+ }
74+ }
5275 ]
5376 }
5477 # Should not raise an error and should count 2 test cases
0 commit comments