From 91d6b5b5d4432852b86c9018569f3c4763e29510 Mon Sep 17 00:00:00 2001 From: Bernie Hackett Date: Wed, 23 Apr 2014 13:24:16 -0700 Subject: [PATCH] PYTHON-676 - Use bytes instead of binary_type --- test/qcheck.py | 5 ++--- test/test_binary.py | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/test/qcheck.py b/test/qcheck.py index df0fdec15..0956b62d5 100644 --- a/test/qcheck.py +++ b/test/qcheck.py @@ -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), diff --git a/test/test_binary.py b/test/test_binary.py index befd49577..c201d9835 100644 --- a/test/test_binary.py +++ b/test/test_binary.py @@ -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.