Fix a few doc test failures.

This commit is contained in:
behackett 2012-02-08 15:30:44 -08:00
parent 0c78e29e08
commit 0c560a5cc4
4 changed files with 15 additions and 13 deletions

View File

@ -136,26 +136,28 @@ class UUIDLegacy(Binary):
.. doctest::
>>> import uuid
>>> from bson.binary import Binary, UUIDLegacy
>>> from bson.binary import Binary, UUIDLegacy, UUID_SUBTYPE
>>> my_uuid = uuid.uuid4()
>>> db.test.insert({'uuid': Binary(my_uuid.bytes, 3)})
>>> coll = db.test
>>> coll.uuid_subtype = UUID_SUBTYPE
>>> coll.insert({'uuid': Binary(my_uuid.bytes, 3)})
ObjectId('...')
>>> db.test.find({'uuid': my_uuid}).count()
>>> coll.find({'uuid': my_uuid}).count()
0
>>> db.test.find({'uuid': UUIDLegacy(my_uuid)}).count()
>>> coll.find({'uuid': UUIDLegacy(my_uuid)}).count()
1
>>> db.test.find({'uuid': UUIDLegacy(my_uuid)})[0]['uuid']
>>> coll.find({'uuid': UUIDLegacy(my_uuid)})[0]['uuid']
UUID('...')
>>>
>>> # Convert from subtype 3 to subtype 4
>>> doc = db.test.find_one({'uuid': UUIDLegacy(my_uuid)})
>>> db.test.save(doc)
>>> doc = coll.find_one({'uuid': UUIDLegacy(my_uuid)})
>>> coll.save(doc)
ObjectId('...')
>>> db.test.find({'uuid': UUIDLegacy(my_uuid)}).count()
>>> coll.find({'uuid': UUIDLegacy(my_uuid)}).count()
0
>>> db.test.find({'uuid': {'$in': [UUIDLegacy(my_uuid), my_uuid]}}).count()
>>> coll.find({'uuid': {'$in': [UUIDLegacy(my_uuid), my_uuid]}}).count()
1
>>> db.test.find_one({'uuid': my_uuid})['uuid']
>>> coll.find_one({'uuid': my_uuid})['uuid']
UUID('...')
Raises TypeError if `obj` is not an instance of :class:`~uuid.UUID`.

View File

@ -78,8 +78,8 @@ Or circle (specified by center point and radius):
... repr(doc)
...
"{u'loc': [1, 2], u'_id': ObjectId('...')}"
"{u'loc': [2, 5], u'_id': ObjectId('...')}"
"{u'loc': [4, 4], u'_id': ObjectId('...')}"
"{u'loc': [2, 5], u'_id': ObjectId('...')}"
geoNear queries are also supported using :class:`~bson.son.SON`:

View File

@ -114,6 +114,6 @@ With MongoDB 1.8.0 or newer you can use :class:`~bson.son.SON` to specify a diff
>>> from bson.son import SON
>>> db.things.map_reduce(mapper, reducer, out=SON([("replace", "results"), ("db", "outdb")]), full_response=True)
{u'counts': {u'input': 4, u'reducer': 2, u'emit': 6, u'output': 3}, u'timeMillis': ..., u'ok': ..., u'result': {u'db': ..., u'collection': ...}}
{u'counts': {u'input': 4, u'reduce': 2, u'emit': 6, u'output': 3}, u'timeMillis': ..., u'ok': ..., u'result': {u'db': ..., u'collection': ...}}
.. seealso:: The full list of options for MongoDB's `map reduce engine <http://www.mongodb.org/display/DOCS/MapReduce>`_

View File

@ -24,7 +24,7 @@ attribute-style access:
.. doctest::
>>> from pymongo import ReplicaSetConnection
>>> c = ReplicaSetConnection('localhost:31017', replicaSet='repl0')
>>> c = ReplicaSetConnection('localhost:27017', replicaSet='repl0')
>>> c.test_database
Database(ReplicaSetConnection([u'...', u'...']), u'test_database')
>>> c['test_database']