File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,11 @@ class Bar(Document):
19
19
bars = Bar .objects .read_preference (
20
20
ReadPreference .SECONDARY_PREFERRED
21
21
).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
26
27
27
28
def test_queryset_aggregation_framework (self ):
28
29
class Person (Document ):
Original file line number Diff line number Diff line change 3
3
import uuid
4
4
5
5
import pymongo
6
+ import pymongo .database
7
+ import pymongo .mongo_client
6
8
import pytest
7
9
from bson .tz_util import utc
8
10
from pymongo import MongoClient , ReadPreference
@@ -608,7 +610,10 @@ def test_connect_with_replicaset_via_kwargs(self):
608
610
connection kwargs
609
611
"""
610
612
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"
612
617
db = get_db ()
613
618
assert isinstance (db , pymongo .database .Database )
614
619
assert db .name == "test"
You can’t perform that action at this time.
0 commit comments