(self)
| 1093 | self.assertNotIn(new_file, [os.path.basename(f) for f in coder.abs_fnames]) |
| 1094 | |
| 1095 | def test_show_exhausted_error(self): |
| 1096 | with GitTemporaryDirectory(): |
| 1097 | io = InputOutput(yes=True) |
| 1098 | coder = Coder.create(self.GPT35, "diff", io=io) |
| 1099 | |
| 1100 | # Set up some real done_messages and cur_messages |
| 1101 | coder.done_messages = [ |
| 1102 | {"role": "user", "content": "Hello, can you help me with a Python problem?"}, |
| 1103 | { |
| 1104 | "role": "assistant", |
| 1105 | "content": "Of course! I'd be happy to help. What's the problem you're facing?", |
| 1106 | }, |
| 1107 | { |
| 1108 | "role": "user", |
| 1109 | "content": ( |
| 1110 | "I need to write a function that calculates the factorial of a number." |
| 1111 | ), |
| 1112 | }, |
| 1113 | { |
| 1114 | "role": "assistant", |
| 1115 | "content": ( |
| 1116 | "Sure, I can help you with that. Here's a simple Python function to" |
| 1117 | " calculate the factorial of a number:" |
| 1118 | ), |
| 1119 | }, |
| 1120 | ] |
| 1121 | |
| 1122 | coder.cur_messages = [ |
| 1123 | {"role": "user", "content": "Can you optimize this function for large numbers?"}, |
| 1124 | ] |
| 1125 | |
| 1126 | # Set up real values for the main model |
| 1127 | coder.main_model.info = { |
| 1128 | "max_input_tokens": 4000, |
| 1129 | "max_output_tokens": 1000, |
| 1130 | } |
| 1131 | coder.partial_response_content = ( |
| 1132 | "Here's an optimized version of the factorial function:" |
| 1133 | ) |
| 1134 | coder.io.tool_error = MagicMock() |
| 1135 | |
| 1136 | # Call the method |
| 1137 | coder.show_exhausted_error() |
| 1138 | |
| 1139 | # Check if tool_error was called with the expected message |
| 1140 | coder.io.tool_error.assert_called() |
| 1141 | error_message = coder.io.tool_error.call_args[0][0] |
| 1142 | |
| 1143 | # Assert that the error message contains the expected information |
| 1144 | self.assertIn("Model gpt-3.5-turbo has hit a token limit!", error_message) |
| 1145 | self.assertIn("Input tokens:", error_message) |
| 1146 | self.assertIn("Output tokens:", error_message) |
| 1147 | self.assertIn("Total tokens:", error_message) |
| 1148 | |
| 1149 | def test_keyboard_interrupt_handling(self): |
| 1150 | with GitTemporaryDirectory(): |
nothing calls this directly
no test coverage detected