Skip to content

Commit e05d3ba

Browse files
committed
Add test for Decimal128.
1 parent bf879f9 commit e05d3ba

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/test_bsonjs.py

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from bson.binary import Binary, MD5_SUBTYPE, USER_DEFINED_SUBTYPE
2525
from bson.code import Code
2626
from bson.codec_options import CodecOptions
27+
from bson.decimal128 import Decimal128
2728
from bson.dbref import DBRef
2829
from bson.int64 import Int64
2930
from bson.max_key import MaxKey
@@ -84,6 +85,13 @@ def test_basic(self):
8485
def test_objectid(self):
8586
self.round_trip({"id": ObjectId()})
8687

88+
def test_decimal128(self):
89+
decimal_doc = {"d": Decimal128("12123.000000000003")}
90+
self.round_trip(decimal_doc)
91+
self.assertEqual(
92+
'{ "d" : { "$numberDecimal" : "12123.000000000003" } }',
93+
bsonjs_dumps(decimal_doc))
94+
8795
def test_dbref(self):
8896
self.round_trip({"ref": DBRef("foo", 5)})
8997
self.round_trip({"ref": DBRef("foo", 5, "db")})

0 commit comments

Comments
 (0)