MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / test_base64_file_input

Function test_base64_file_input

tests/test_transform.py:410–425  ·  view source on GitHub ↗
(use_async: bool)

Source from the content-addressed store, hash-verified

408@parametrize
409@pytest.mark.asyncio
410async def test_base64_file_input(use_async: bool) -> None:
411 # strings are left as-is
412 assert await transform({"foo": "bar"}, TypedDictBase64Input, use_async) == {"foo": "bar"}
413
414 # pathlib.Path is automatically converted to base64
415 assert await transform({"foo": SAMPLE_FILE_PATH}, TypedDictBase64Input, use_async) == {
416 "foo": "SGVsbG8sIHdvcmxkIQo="
417 } # type: ignore[comparison-overlap]
418
419 # io instances are automatically converted to base64
420 assert await transform({"foo": io.StringIO("Hello, world!")}, TypedDictBase64Input, use_async) == {
421 "foo": "SGVsbG8sIHdvcmxkIQ=="
422 } # type: ignore[comparison-overlap]
423 assert await transform({"foo": io.BytesIO(b"Hello, world!")}, TypedDictBase64Input, use_async) == {
424 "foo": "SGVsbG8sIHdvcmxkIQ=="
425 } # type: ignore[comparison-overlap]

Callers

nothing calls this directly

Calls 1

transformFunction · 0.70

Tested by

no test coverage detected