Skip to content

Commit 0c560a5

Browse files
committed
Fix a few doc test failures.
1 parent 0c78e29 commit 0c560a5

4 files changed

Lines changed: 15 additions & 13 deletions

File tree

bson/binary.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,26 +136,28 @@ class UUIDLegacy(Binary):
136136
.. doctest::
137137
138138
>>> import uuid
139-
>>> from bson.binary import Binary, UUIDLegacy
139+
>>> from bson.binary import Binary, UUIDLegacy, UUID_SUBTYPE
140140
>>> my_uuid = uuid.uuid4()
141-
>>> db.test.insert({'uuid': Binary(my_uuid.bytes, 3)})
141+
>>> coll = db.test
142+
>>> coll.uuid_subtype = UUID_SUBTYPE
143+
>>> coll.insert({'uuid': Binary(my_uuid.bytes, 3)})
142144
ObjectId('...')
143-
>>> db.test.find({'uuid': my_uuid}).count()
145+
>>> coll.find({'uuid': my_uuid}).count()
144146
0
145-
>>> db.test.find({'uuid': UUIDLegacy(my_uuid)}).count()
147+
>>> coll.find({'uuid': UUIDLegacy(my_uuid)}).count()
146148
1
147-
>>> db.test.find({'uuid': UUIDLegacy(my_uuid)})[0]['uuid']
149+
>>> coll.find({'uuid': UUIDLegacy(my_uuid)})[0]['uuid']
148150
UUID('...')
149151
>>>
150152
>>> # Convert from subtype 3 to subtype 4
151-
>>> doc = db.test.find_one({'uuid': UUIDLegacy(my_uuid)})
152-
>>> db.test.save(doc)
153+
>>> doc = coll.find_one({'uuid': UUIDLegacy(my_uuid)})
154+
>>> coll.save(doc)
153155
ObjectId('...')
154-
>>> db.test.find({'uuid': UUIDLegacy(my_uuid)}).count()
156+
>>> coll.find({'uuid': UUIDLegacy(my_uuid)}).count()
155157
0
156-
>>> db.test.find({'uuid': {'$in': [UUIDLegacy(my_uuid), my_uuid]}}).count()
158+
>>> coll.find({'uuid': {'$in': [UUIDLegacy(my_uuid), my_uuid]}}).count()
157159
1
158-
>>> db.test.find_one({'uuid': my_uuid})['uuid']
160+
>>> coll.find_one({'uuid': my_uuid})['uuid']
159161
UUID('...')
160162
161163
Raises TypeError if `obj` is not an instance of :class:`~uuid.UUID`.

doc/examples/geo.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Or circle (specified by center point and radius):
7878
... repr(doc)
7979
...
8080
"{u'loc': [1, 2], u'_id': ObjectId('...')}"
81-
"{u'loc': [2, 5], u'_id': ObjectId('...')}"
8281
"{u'loc': [4, 4], u'_id': ObjectId('...')}"
82+
"{u'loc': [2, 5], u'_id': ObjectId('...')}"
8383

8484
geoNear queries are also supported using :class:`~bson.son.SON`:
8585

doc/examples/map_reduce.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@ With MongoDB 1.8.0 or newer you can use :class:`~bson.son.SON` to specify a diff
114114

115115
>>> from bson.son import SON
116116
>>> db.things.map_reduce(mapper, reducer, out=SON([("replace", "results"), ("db", "outdb")]), full_response=True)
117-
{u'counts': {u'input': 4, u'reducer': 2, u'emit': 6, u'output': 3}, u'timeMillis': ..., u'ok': ..., u'result': {u'db': ..., u'collection': ...}}
117+
{u'counts': {u'input': 4, u'reduce': 2, u'emit': 6, u'output': 3}, u'timeMillis': ..., u'ok': ..., u'result': {u'db': ..., u'collection': ...}}
118118

119119
.. seealso:: The full list of options for MongoDB's `map reduce engine <http://www.mongodb.org/display/DOCS/MapReduce>`_

pymongo/replica_set_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
.. doctest::
2525
2626
>>> from pymongo import ReplicaSetConnection
27-
>>> c = ReplicaSetConnection('localhost:31017', replicaSet='repl0')
27+
>>> c = ReplicaSetConnection('localhost:27017', replicaSet='repl0')
2828
>>> c.test_database
2929
Database(ReplicaSetConnection([u'...', u'...']), u'test_database')
3030
>>> c['test_database']

0 commit comments

Comments
 (0)