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
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ def write_float_value(self, key: Optional[str], value: Optional[float]) -> None:
key (Optional[str]): The key to be used for the written value. May be null.
value (Optional[float]): The float value to be written.
"""
if isinstance(value, float):
if isinstance(value, (float, int)):
if key:
self.writer[key] = value
self.writer[key] = float(value)
else:
self.value = value
self.value = float(value)

def write_uuid_value(self, key: Optional[str], value: Optional[UUID]) -> None:
"""Writes the specified uuid value to the stream with an optional given key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ def test_write_float_value():
assert content_string == '{"gpa": 3.2}'


def test_write_float_value_with_int():
json_serialization_writer = JsonSerializationWriter()
json_serialization_writer.write_float_value("float", 3)
content = json_serialization_writer.get_serialized_content()
content_string = content.decode("utf-8")
assert content_string == '{"float": 3.0}'


def test_write_uuid_value():
json_serialization_writer = JsonSerializationWriter()
json_serialization_writer.write_uuid_value("id", UUID("8f841f30-e6e3-439a-a812-ebd369559c36"))
Expand Down