Skip to content

Commit c9cecaa

Browse files
committed
Merge pull request #47 from radeklos/feature/coerce-float
Coerce float type in Float type
2 parents b441be6 + 4036187 commit c9cecaa

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.9
1+
0.1.10

kim/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def serialize_value(self, source_value):
572572
if self.as_string:
573573
return str(source_value)
574574
else:
575-
return source_value
575+
return float(source_value)
576576

577577
def marshal_value(self, source_value):
578578
return float(source_value)

tests/test_types.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,13 @@ def test_marshal_as_string(self):
524524

525525
self.assertEqual(result, 1.343)
526526

527+
def test_coerce_float(self):
528+
my_type = Float()
529+
result = my_type.serialize_value(int(5))
530+
531+
self.assertIsInstance(result, float)
532+
self.assertEqual(result, 5.0)
533+
527534

528535
class DecimalTypeTests(unittest.TestCase):
529536

0 commit comments

Comments
 (0)