test_json.py — anthropic-sdk-python Source File
Architecture documentation for test_json.py, a python file in the anthropic-sdk-python codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2f59920a_6eb4_4ce0_f827_6c42982acc91["test_json.py"] 7e1d14c5_475e_409c_7c4e_1274f9d40aa9["datetime"] 2f59920a_6eb4_4ce0_f827_6c42982acc91 --> 7e1d14c5_475e_409c_7c4e_1274f9d40aa9 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"] 2f59920a_6eb4_4ce0_f827_6c42982acc91 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875 21de8837_7dae_989e_fdbb_1415c0770d90["pydantic"] 2f59920a_6eb4_4ce0_f827_6c42982acc91 --> 21de8837_7dae_989e_fdbb_1415c0770d90 d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"] 2f59920a_6eb4_4ce0_f827_6c42982acc91 --> d10c5377_2939_0f0b_cc44_8759393f2853 ccdbb5aa_0162_e9b1_a84f_86b489e8b2bf["anthropic._utils._json"] 2f59920a_6eb4_4ce0_f827_6c42982acc91 --> ccdbb5aa_0162_e9b1_a84f_86b489e8b2bf style 2f59920a_6eb4_4ce0_f827_6c42982acc91 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import datetime
from typing import Union
import pydantic
from anthropic import _compat
from anthropic._utils._json import openapi_dumps
class TestOpenapiDumps:
def test_basic(self) -> None:
data = {"key": "value", "number": 42}
json_bytes = openapi_dumps(data)
assert json_bytes == b'{"key":"value","number":42}'
def test_datetime_serialization(self) -> None:
dt = datetime.datetime(2023, 1, 1, 12, 0, 0)
data = {"datetime": dt}
json_bytes = openapi_dumps(data)
assert json_bytes == b'{"datetime":"2023-01-01T12:00:00"}'
def test_pydantic_model_serialization(self) -> None:
class User(pydantic.BaseModel):
first_name: str
last_name: str
age: int
model_instance = User(first_name="John", last_name="Kramer", age=83)
data = {"model": model_instance}
json_bytes = openapi_dumps(data)
assert json_bytes == b'{"model":{"first_name":"John","last_name":"Kramer","age":83}}'
def test_pydantic_model_with_default_values(self) -> None:
class User(pydantic.BaseModel):
name: str
role: str = "user"
active: bool = True
score: int = 0
model_instance = User(name="Alice")
data = {"model": model_instance}
json_bytes = openapi_dumps(data)
assert json_bytes == b'{"model":{"name":"Alice"}}'
def test_pydantic_model_with_default_values_overridden(self) -> None:
class User(pydantic.BaseModel):
name: str
role: str = "user"
active: bool = True
model_instance = User(name="Bob", role="admin", active=False)
data = {"model": model_instance}
json_bytes = openapi_dumps(data)
assert json_bytes == b'{"model":{"name":"Bob","role":"admin","active":false}}'
def test_pydantic_model_with_alias(self) -> None:
class User(pydantic.BaseModel):
first_name: str = pydantic.Field(alias="firstName")
// ... (67 more lines)
Domain
Subdomains
Classes
Dependencies
- anthropic
- anthropic._utils._json
- datetime
- pydantic
- typing
Source
Frequently Asked Questions
What does test_json.py do?
test_json.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What does test_json.py depend on?
test_json.py imports 5 module(s): anthropic, anthropic._utils._json, datetime, pydantic, typing.
Where is test_json.py in the architecture?
test_json.py is located at tests/test_utils/test_json.py (domain: AnthropicClient, subdomain: SyncAPI, directory: tests/test_utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free