MCPcopy Create free account
hub / github.com/ScrapeGraphAI/toonify / test_exclude_none

Method test_exclude_none

tests/test_pydantic.py:97–112  ·  view source on GitHub ↗

Test excluding None values.

(self)

Source from the content-addressed store, hash-verified

95 assert 'debug' not in toon_set
96
97 def test_exclude_none(self):
98 """Test excluding None values."""
99 class User(BaseModel):
100 id: int
101 name: str
102 email: str | None = None # Use | syntax for Python 3.10+
103
104 user = User(id=1, name='Alice', email=None)
105
106 # With exclude_none=False (default)
107 toon_all = encode_pydantic(user, exclude_none=False)
108 assert 'email: null' in toon_all
109
110 # With exclude_none=True
111 toon_no_none = encode_pydantic(user, exclude_none=True)
112 assert 'email' not in toon_no_none
113
114 def test_by_alias(self):
115 """Test using field aliases."""

Callers

nothing calls this directly

Calls 2

encode_pydanticFunction · 0.90
UserClass · 0.70

Tested by

no test coverage detected