Skip to content

Commit

Permalink
Huge string test
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Jul 30, 2024
1 parent 8882de2 commit dd5d6f9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/serializers/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ def test_str():
assert json.loads(json_emoji) == 'emoji 💩'


def test_huge_str():
v = SchemaSerializer(core_schema.int_schema())
msg = "Expected `int` but got `str` with value `'123456789012345678901234...89012345678901234567890'` - serialized value may not be as expected"
with pytest.warns(UserWarning, match=msg):
v.to_python(
'12345678901234567890123456789012345678901234567890123456789012345678901234567890\
12345678901234567890123456789012345678901234567890123456789012345678901234567890\
12345678901234567890123456789012345678901234567890123456789012345678901234567890\
12345678901234567890123456789012345678901234567890123456789012345678901234567890'
)


def test_str_fallback():
s = SchemaSerializer(core_schema.str_schema())
assert s.to_python(None) is None
Expand Down

0 comments on commit dd5d6f9

Please sign in to comment.