@@ -649,21 +649,33 @@ def test_warns_on_empty_content_with_length_finish(self, caplog):
649649
650650 response = LLMResponse (content = "" , finish_reason = "length" )
651651 with caplog .at_level ("WARNING" ):
652- warn_if_truncated (response , "self_check_input" )
652+ result = warn_if_truncated (response , "self_check_input" )
653+ assert result is True
653654 assert any ("self_check_input" in rec .message and "length" in rec .message for rec in caplog .records )
654655
655656 def test_silent_on_non_empty_content (self , caplog ):
656657 from nemoguardrails .types import LLMResponse
657658
658659 response = LLMResponse (content = "yes" , finish_reason = "length" )
659660 with caplog .at_level ("WARNING" ):
660- warn_if_truncated (response , "self_check_input" )
661+ result = warn_if_truncated (response , "self_check_input" )
662+ assert result is False
661663 assert not caplog .records
662664
663665 def test_silent_on_non_length_finish_reason (self , caplog ):
664666 from nemoguardrails .types import LLMResponse
665667
666668 response = LLMResponse (content = "" , finish_reason = "stop" )
667669 with caplog .at_level ("WARNING" ):
668- warn_if_truncated (response , "self_check_input" )
670+ result = warn_if_truncated (response , "self_check_input" )
671+ assert result is False
672+ assert not caplog .records
673+
674+ def test_silent_on_none_finish_reason (self , caplog ):
675+ from nemoguardrails .types import LLMResponse
676+
677+ response = LLMResponse (content = "" , finish_reason = None )
678+ with caplog .at_level ("WARNING" ):
679+ result = warn_if_truncated (response , "self_check_input" )
680+ assert result is False
669681 assert not caplog .records
0 commit comments