Skip to content

Commit 37762ab

Browse files
Elijah Fredericksonbagerard
authored andcommitted
The WebIDE will only take you so far
1 parent dbf7888 commit 37762ab

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

tests/queryset/test_queryset_aggregation.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ class Bar(Document):
1919
bars = Bar.objects.read_preference(
2020
ReadPreference.SECONDARY_PREFERRED
2121
).aggregate(pipeline)
22-
assert (
23-
bars._CommandCursor__collection.read_preference
24-
== ReadPreference.SECONDARY_PREFERRED
25-
)
22+
if hasattr(bars, "_CommandCursor__collection"):
23+
read_pref = bars._CommandCursor__collection.read_preference
24+
else: # pymongo >= 4.9
25+
read_pref = bars._collection.read_preference
26+
assert read_pref == ReadPreference.SECONDARY_PREFERRED
2627

2728
def test_queryset_aggregation_framework(self):
2829
class Person(Document):

tests/test_connection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import uuid
44

55
import pymongo
6+
import pymongo.database
7+
import pymongo.mongo_client
68
import pytest
79
from bson.tz_util import utc
810
from pymongo import MongoClient, ReadPreference
@@ -608,7 +610,10 @@ def test_connect_with_replicaset_via_kwargs(self):
608610
connection kwargs
609611
"""
610612
c = connect(replicaset="local-rs")
611-
assert c._MongoClient__options.replica_set_name == "local-rs"
613+
if hasattr(c, "_MongoClient__options"):
614+
assert c._MongoClient__options.replica_set_name == "local-rs"
615+
else: # pymongo >= 4.9
616+
assert c._options.replica_set_name == "local-rs"
612617
db = get_db()
613618
assert isinstance(db, pymongo.database.Database)
614619
assert db.name == "test"

0 commit comments

Comments
 (0)