mongodb-labs / python-bsonjs

A fast BSON to MongoDB Extended JSON converter for Python - This Repository is NOT a supported MongoDB product
Apache License 2.0
40 stars 10 forks source link

Fix test_binary test failure #24

Closed ShaneHarvey closed 4 years ago

ShaneHarvey commented 4 years ago

PyMongo loads $binary subtype 0 as bytes in Python 3.

Fixes https://github.com/mongodb-labs/python-bsonjs/issues/21:

FAIL: test_binary (test.test_bsonjs.TestBsonjs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/julius/python-bsonjs/test/test_bsonjs.py", line 195, in test_binary
    self.round_trip(bin_type_dict)
  File "/Users/julius/python-bsonjs/test/test_bsonjs.py", line 79, in round_trip
    self.assertEqual(doc, json_util.loads(
AssertionError: {'bin': Binary(b'\x00\x01\x02\x03\x04', 0)} != {'bin': b'\x00\x01\x02\x03\x04'}
- {'bin': Binary(b'\x00\x01\x02\x03\x04', 0)}
?         -------                       ----
+ {'bin': b'\x00\x01\x02\x03\x04'}
ShaneHarvey commented 4 years ago

The Travis failures are for Python 2.6 and 3.3.