Souravdanyal commited on
Commit
de1fd70
·
1 Parent(s): 509f816

Removed file from github tracking

Browse files
Files changed (1) hide show
  1. test_edge_cases.py +0 -80
test_edge_cases.py DELETED
@@ -1,80 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Test edge cases that might cause 500 errors"""
3
-
4
- from server.tasks.task_easy import get_task_by_id
5
- from server.graders.grader_easy import grade_easy
6
-
7
- # Test easy_014 with potentially bad code
8
- task = get_task_by_id('easy_014')
9
-
10
- print("="*60)
11
- print("Testing easy_014 with various bad codes")
12
- print("="*60)
13
-
14
- # Test 1: Code with infinite loop
15
- print("\n1. Testing with infinite loop code:")
16
- bad_code1 = """
17
- def longest_word_length(sentence):
18
- while True:
19
- pass
20
- """
21
- try:
22
- reward, passed, total, feedback, results = grade_easy(bad_code1, task)
23
- print(f"Result: {passed}/{total}, reward={reward}")
24
- print(f"Feedback: {feedback[:200]}...")
25
- except Exception as e:
26
- print(f"ERROR: {type(e).__name__}: {e}")
27
-
28
- # Test 2: Code that doesn't return anything
29
- print("\n2. Testing with code that returns None:")
30
- bad_code2 = """
31
- def longest_word_length(sentence):
32
- words = sentence.split()
33
- # forgot to return
34
- """
35
- try:
36
- reward, passed, total, feedback, results = grade_easy(bad_code2, task)
37
- print(f"Result: {passed}/{total}, reward={reward}")
38
- print(f"Feedback: {feedback[:200]}...")
39
- except Exception as e:
40
- print(f"ERROR: {type(e).__name__}: {e}")
41
-
42
- # Test 3: Code with syntax error
43
- print("\n3. Testing with syntax error:")
44
- bad_code3 = """
45
- def longest_word_length(sentence:
46
- return max(len(w) for w in sentence.split())
47
- """
48
- try:
49
- reward, passed, total, feedback, results = grade_easy(bad_code3, task)
50
- print(f"Result: {passed}/{total}, reward={reward}")
51
- print(f"Feedback: {feedback[:200]}...")
52
- except Exception as e:
53
- print(f"ERROR: {type(e).__name__}: {e}")
54
-
55
- # Test 4: Code with empty string input handling issue
56
- print("\n4. Testing with code that might fail on empty string:")
57
- bad_code4 = """
58
- def longest_word_length(sentence):
59
- words = sentence.split()
60
- return max(len(w) for w in words) # This will fail if words is empty!
61
- """
62
- try:
63
- # Temporarily add an empty string test
64
- task_copy = task.copy()
65
- task_copy['test_cases'] = [{"input": "", "expected": 0}]
66
- reward, passed, total, feedback, results = grade_easy(bad_code4, task_copy)
67
- print(f"Result: {passed}/{total}, reward={reward}")
68
- print(f"Feedback: {feedback[:200]}...")
69
- except Exception as e:
70
- print(f"ERROR: {type(e).__name__}: {e}")
71
-
72
- # Test 5: Normal test cases
73
- print("\n5. Testing with normal test cases:")
74
- try:
75
- reward, passed, total, feedback, results = grade_easy(bad_code4, task)
76
- print(f"Result: {passed}/{total}, reward={reward}")
77
- for result in results:
78
- print(f" Test {result['test_id']}: {'✅' if result['passed'] else '❌'} - expected={result['expected']}, got={result['got']}")
79
- except Exception as e:
80
- print(f"ERROR: {type(e).__name__}: {e}")