-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_generator.py
More file actions
38 lines (32 loc) · 1.06 KB
/
fix_generator.py
File metadata and controls
38 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
"""
Fix the generate_all_tests.py file to properly indent multi-line test code.
"""
# Read the file
with open('generate_all_tests.py', 'r') as f:
content = f.read()
# Replace the problematic line 176
old_code = ''' for i, (name, test_code) in enumerate(s['tests'], 1):
code += f\'\'\' try:
{test_code}
self.add_result("{name}", True)
except Exception as e:
self.add_result("{name}", False, str(e))
\'\'\'
'''
new_code = ''' for i, (name, test_code) in enumerate(s['tests'], 1):
# Split test_code and properly indent each line
test_lines = test_code.split('\\n')
indented_code = '\\n '.join(test_lines)
code += f\'\'\' try:
{indented_code}
self.add_result("{name}", True)
except Exception as e:
self.add_result("{name}", False, str(e))
\'\'\'
'''
content = content.replace(old_code, new_code)
# Write back
with open('generate_all_tests.py', 'w') as f:
f.write(content)
print("Fixed generator!")