Unverified Commit 5f6fa04a authored by yichuan~'s avatar yichuan~ Committed by GitHub
Browse files

misc: simplify test (#964)

parent 58a09708
...@@ -313,22 +313,12 @@ class TestOpenAIServer(unittest.TestCase): ...@@ -313,22 +313,12 @@ class TestOpenAIServer(unittest.TestCase):
result_file_id = batch_job.output_file_id result_file_id = batch_job.output_file_id
file_response = client.files.content(result_file_id) file_response = client.files.content(result_file_id)
result_content = file_response.read() result_content = file_response.read().decode("utf-8") # Decode bytes to string
results = [
if mode == "completion": json.loads(line)
result_file_name = "batch_job_complete_results.jsonl" for line in result_content.split("\n")
else: if line.strip() != ""
result_file_name = "batch_job_chat_results.jsonl" ]
with open(result_file_name, "wb") as file:
file.write(result_content)
results = []
with open(result_file_name, "r", encoding="utf-8") as file:
for line in file:
json_object = json.loads(line.strip())
results.append(json_object)
for delete_fid in [uploaded_file.id, result_file_id]:
del_pesponse = client.files.delete(delete_fid)
assert del_pesponse.deleted
assert len(results) == len(content) assert len(results) == len(content)
def test_completion(self): def test_completion(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment