PYTHON-676 - Use bytes instead of binary_type

This commit is contained in:
Bernie Hackett 2014-04-23 13:24:16 -07:00
parent 35410a22e3
commit 91d6b5b5d4
2 changed files with 4 additions and 7 deletions

View File

@ -22,7 +22,7 @@ sys.path[0:0] = [""]
from bson.binary import Binary
from bson.dbref import DBRef
from bson.objectid import ObjectId
from bson.py3compat import MAXSIZE, PY3, binary_type, iteritems, u
from bson.py3compat import MAXSIZE, PY3, iteritems, u
from bson.son import SON
if PY3:
@ -155,8 +155,7 @@ def gen_mongo_value(depth, ref):
# If we used Binary in python3 tests would fail since we
# decode BSON binary subtype 0 to bytes. Testing this with
# bytes in python3 makes a lot more sense.
# binary_type is `str` in python 2, `bytes` in python 3.
bintype = binary_type
bintype = bytes
choices = [gen_unicode(gen_range(0, 50)),
gen_printable_string(gen_range(0, 50)),
my_map(gen_string(gen_range(0, 1000)), bintype),

View File

@ -30,7 +30,7 @@ sys.path[0:0] = [""]
import bson
from bson.binary import *
from bson.py3compat import binary_type, u
from bson.py3compat import u
from bson.son import SON
from nose.plugins.skip import SkipTest
from test.test_client import get_client
@ -257,9 +257,7 @@ class TestBinary(unittest.TestCase):
coll.drop()
uu = uuid.uuid4()
# Wrap uu.bytes in binary_type to work
# around http://bugs.python.org/issue7380.
coll.insert({'uuid': Binary(binary_type(uu.bytes), 3)})
coll.insert({'uuid': Binary(uu.bytes, 3)})
self.assertEqual(1, coll.count())
# Test UUIDLegacy queries.