MCPcopy Create free account
hub / github.com/catid/supercharger / main

Function main

codegen/test_clean_code.py:89–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87
88
89def main():
90 code, success = clean_code(bad_code)
91
92 if not success:
93 print("Code cleaning failed!")
94 return
95
96 print(f"Cleaned code: {code}")
97
98 # Add this call back into the code
99 code += "\ndostuff()"
100
101 # Test script file name to execute in the Docker container
102 sources_dirname = "test_sources"
103 test_script = "test_script.py"
104 expected_output = """5 + 2 = 7
1055 - 2 = 3
1065 * 2 = 10
1075 / 2 = 2.5
108The area of a circle with radius 3 is 28.27
109The square root of 49 is 7.0
110The maximum value in the list is 91
1117 is a prime number"""
112
113 script_path = os.path.join(os.getcwd(), sources_dirname, test_script)
114 os.makedirs(os.path.join(os.getcwd(), sources_dirname), exist_ok=True)
115
116 # Write a simple test script to execute in the container
117 with open(script_path, "w") as f:
118 f.write(code)
119
120 docker_execute = DockerExecute(sources_dirname=sources_dirname)
121
122 # Prime the pump
123 exit_code, output = docker_execute.execute(test_script)
124 assert output == expected_output, f"Unexpected output: {output}"
125 assert exit_code == 0, f"Unexpected exit code: {exit_code}"
126
127 # Remove the test script file
128 os.remove(script_path)
129
130 print("Success! Script now runs and prints the expected output.")
131
132if __name__ == "__main__":
133 main()

Callers 1

test_clean_code.pyFile · 0.70

Calls 3

executeMethod · 0.95
clean_codeFunction · 0.90
DockerExecuteClass · 0.90

Tested by

no test coverage detected