(self, file_path = None)
| 471 | |
| 472 | |
| 473 | def save_testcases(self, file_path = None): |
| 474 | if len(self.prompt2testcase) == 0: |
| 475 | prompts, overlong_prompts = self.get_all_prompts() |
| 476 | for i, p in enumerate(prompts + overlong_prompts): |
| 477 | self.prompt2testcase[p] = self.get_testcases(p) |
| 478 | |
| 479 | if file_path != None: |
| 480 | with open(file_path, "w") as f: |
| 481 | f.write(json.dumps(self.prompt2testcase, sort_keys=True, indent=4, separators=(',', ': '))) |
| 482 | elif self.data_path != None: |
| 483 | with open(os.path.join(self.data_path, "testcases.json"), "w") as f: |
| 484 | f.write(json.dumps(self.prompt2testcase, sort_keys=True, indent=4, separators=(',', ': '))) |
| 485 | else: |
| 486 | raise ValueError("Cannot find the file path for test cases.") |
| 487 | |
| 488 | |
| 489 | def save_groundtruths(self, file_path = None, solution_file = None): |
no test coverage detected