Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'matplotlib',
'Pillow',
'fastapi',
'pydantic>=1.9.0',
'uvicorn',
],
'full': [
Expand All @@ -63,6 +64,7 @@
'scipy',
'av',
'fastapi',
'pydantic>=1.9.0',
'uvicorn',
'strawberry-graphql',
],
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@ def test_tags_int_float_str_bool(tag_type, tag_value, protocol):
assert isinstance(dd, tag_type)


@pytest.mark.parametrize('protocol', ['protobuf', 'jsonschema'])
def test_infinity_no_coercion(protocol):
# Test for issue #948: https://github.com/docarray/docarray/issues/948
d = Document()
d.tags['title'] = 'Infinity'

d_pydantic = d.to_pydantic_model()
d_pydantic.tags['title'] = 'Infinity'

d_json = d.to_json(protocol=protocol)
assert '"title": "Infinity"' in d_json

d_dict = d.to_dict(protocol=protocol)
assert d_dict['tags']['title'] == 'Infinity'


@pytest.mark.parametrize(
'blob', [None, b'123', bytes(Document()), bytes(bytearray(os.urandom(512 * 4)))]
)
Expand Down