Skip to content

Commit 42085ad

Browse files
committed
tests: fix incorrect assertion indices in log_outputs tests
The assertions in log_outputs test methods were checking wrong argument indices from mocked logger calls, causing tests to validate incorrect behavior and pass incorrectly. The logger.info call signature is: logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason) Fixed argument index assertions in all affected test methods: - test_request_logger_log_outputs - test_request_logger_log_outputs_streaming_delta - test_request_logger_log_outputs_streaming_complete - test_request_logger_log_outputs_with_truncation - test_request_logger_log_outputs_none_values - test_request_logger_log_outputs_empty_output - test_request_logger_log_outputs_integration Tests now correctly validate outputs at index 3, output_token_ids at index 4, and finish_reason at index 5, instead of the previous incorrect indices 1, 2, and 3 respectively. Signed-off-by: Adrian Garcia <adrian.garcia@inceptionai.ai>
1 parent fb13841 commit 42085ad

File tree

1 file changed

+46
-30
lines changed

1 file changed

+46
-30
lines changed

tests/test_logger.py

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,13 @@ def test_request_logger_log_outputs():
281281
)
282282

283283
mock_logger.info.assert_called_once()
284-
call_args = mock_logger.info.call_args[0]
285-
assert "Generated response test-123" in call_args[0]
286-
assert "Hello, world!" in call_args[1]
287-
assert call_args[2] == [1, 2, 3, 4]
288-
assert call_args[3] == "stop"
284+
call_args = mock_logger.info.call_args.args
285+
# logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
286+
assert "Generated response %s%s" in call_args[0]
287+
assert call_args[1] == "test-123"
288+
assert call_args[3] == "Hello, world!"
289+
assert call_args[4] == [1, 2, 3, 4]
290+
assert call_args[5] == "stop"
289291

290292

291293
def test_request_logger_log_outputs_streaming_delta():
@@ -306,11 +308,14 @@ def test_request_logger_log_outputs_streaming_delta():
306308
)
307309

308310
mock_logger.info.assert_called_once()
309-
call_args = mock_logger.info.call_args[0]
310-
assert "Generated response test-456 (streaming delta)" in call_args[0]
311-
assert call_args[1] == "Hello"
312-
assert call_args[2] == [1]
313-
assert call_args[3] is None
311+
call_args = mock_logger.info.call_args.args
312+
# logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
313+
assert "Generated response %s%s" in call_args[0]
314+
assert call_args[1] == "test-456"
315+
assert call_args[2] == " (streaming delta)"
316+
assert call_args[3] == "Hello"
317+
assert call_args[4] == [1]
318+
assert call_args[5] is None
314319

315320

316321
def test_request_logger_log_outputs_streaming_complete():
@@ -331,12 +336,14 @@ def test_request_logger_log_outputs_streaming_complete():
331336
)
332337

333338
mock_logger.info.assert_called_once()
334-
call_args = mock_logger.info.call_args[0]
335-
assert ("Generated response test-789 (streaming complete)"
336-
in call_args[0])
337-
assert call_args[1] == "Complete response"
338-
assert call_args[2] == [1, 2, 3]
339-
assert call_args[3] == "length"
339+
call_args = mock_logger.info.call_args.args
340+
# logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
341+
assert "Generated response %s%s" in call_args[0]
342+
assert call_args[1] == "test-789"
343+
assert call_args[2] == " (streaming complete)"
344+
assert call_args[3] == "Complete response"
345+
assert call_args[4] == [1, 2, 3]
346+
assert call_args[5] == "length"
340347

341348

342349
def test_request_logger_log_outputs_with_truncation():
@@ -364,12 +371,12 @@ def test_request_logger_log_outputs_with_truncation():
364371
call_args = mock_logger.info.call_args
365372

366373
# Check that output was truncated to first 10 characters
367-
logged_output = call_args[0][1]
374+
logged_output = call_args[0][3]
368375
assert logged_output == "This is a "
369376
assert len(logged_output) == 10
370377

371378
# Check that token IDs were truncated to first 10 tokens
372-
logged_token_ids = call_args[0][2]
379+
logged_token_ids = call_args[0][4]
373380
assert logged_token_ids == list(range(10))
374381
assert len(logged_token_ids) == 10
375382

@@ -392,11 +399,13 @@ def test_request_logger_log_outputs_none_values():
392399
)
393400

394401
mock_logger.info.assert_called_once()
395-
call_args = mock_logger.info.call_args[0]
396-
assert "Generated response test-none" in call_args[0]
397-
assert call_args[1] == "Test output"
398-
assert call_args[2] is None
399-
assert call_args[3] == "stop"
402+
call_args = mock_logger.info.call_args.args
403+
# logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
404+
assert "Generated response %s%s" in call_args[0]
405+
assert call_args[1] == "test-none"
406+
assert call_args[3] == "Test output"
407+
assert call_args[4] is None
408+
assert call_args[5] == "stop"
400409

401410

402411
def test_request_logger_log_outputs_empty_output():
@@ -417,11 +426,13 @@ def test_request_logger_log_outputs_empty_output():
417426
)
418427

419428
mock_logger.info.assert_called_once()
420-
call_args = mock_logger.info.call_args[0]
421-
assert "Generated response test-empty" in call_args[0]
422-
assert call_args[1] == ""
423-
assert call_args[2] == []
424-
assert call_args[3] == "stop"
429+
call_args = mock_logger.info.call_args.args
430+
# logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
431+
assert "Generated response %s%s" in call_args[0]
432+
assert call_args[1] == "test-empty"
433+
assert call_args[3] == ""
434+
assert call_args[4] == []
435+
assert call_args[5] == "stop"
425436

426437

427438
def test_request_logger_log_outputs_integration():
@@ -458,5 +469,10 @@ def test_request_logger_log_outputs_integration():
458469
input_call = mock_logger.info.call_args_list[0][0]
459470
output_call = mock_logger.info.call_args_list[1][0]
460471

461-
assert "Received request test-integration" in input_call[0]
462-
assert "Generated response test-integration" in output_call[0]
472+
# Check input call: logger.info(format_string, request_id, prompt, params, ...)
473+
assert "Received request %s" in input_call[0]
474+
assert input_call[1] == "test-integration"
475+
476+
# Check output call: logger.info(format_string, request_id, stream_info, outputs, ...)
477+
assert "Generated response %s%s" in output_call[0]
478+
assert output_call[1] == "test-integration"

0 commit comments

Comments
 (0)