test(utils): add edge-case coverage for is_base64_encoded

Adds parametrized cases for malformed input (empty string, missing comma,
non-base64 payload) and a valid text data URI. Test-only change; the
existing PNG and "Dog" cases are already covered by
test_is_base64_encoded_2.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UqediyVH1ZRdT3eJqoz2bY
This commit is contained in:
Shalmankursheeth 2026-11-01 08:34:04 +00:00 • committed by Shalman
parent 60fc121ce8
commit c8b0c2d0e1

View file

@ -9872,6 +9872,26 @@ def test_is_base64_encoded_2():
assert is_base64_encoded(s="Dog") is False
@pytest.mark.parametrize(
"value",
[
"",
"data:text/plain;base64",
"data:text/plain;base64,!!!not-base64!!!",
],
)
def test_is_base64_encoded_rejects_malformed_input(value):
from litellm.utils import is_base64_encoded
assert is_base64_encoded(s=value) is False
def test_is_base64_encoded_accepts_text_data_uri():
from litellm.utils import is_base64_encoded
assert is_base64_encoded(s="data:text/plain;base64,aGVsbG8gd29ybGQ=") is True
@pytest.mark.parametrize(
"messages, expected_bool",
[