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):
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 ):
Original file line number Diff line number Diff line change 33import uuid
44
55import pymongo
6+ import pymongo .database
7+ import pymongo .mongo_client
68import pytest
79from bson .tz_util import utc
810from 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"
You can’t perform that action at this time.
0 commit comments