2121 QuerySetManager ,
2222 queryset_manager ,
2323)
24- from tests .utils import requires_mongodb_gte_44
24+ from tests .utils import (
25+ requires_mongodb_gte_44 ,
26+ requires_mongodb_lt_42 ,
27+ requires_mongodb_lte_42 ,
28+ )
2529
2630
2731class db_ops_tracker (query_counter ):
@@ -1490,6 +1494,7 @@ class BlogPost(Document):
14901494
14911495 BlogPost .drop_collection ()
14921496
1497+ @requires_mongodb_lt_42
14931498 def test_exec_js_query (self ):
14941499 """Ensure that queries are properly formed for use in exec_js."""
14951500
@@ -1527,6 +1532,7 @@ class BlogPost(Document):
15271532
15281533 BlogPost .drop_collection ()
15291534
1535+ @requires_mongodb_lt_42
15301536 def test_exec_js_field_sub (self ):
15311537 """Ensure that field substitutions occur properly in exec_js functions."""
15321538
@@ -3109,6 +3115,7 @@ class Person(Document):
31093115 freq = Person .objects .item_frequencies ("city" , normalize = True , map_reduce = True )
31103116 assert freq == {"CRB" : 0.5 , None : 0.5 }
31113117
3118+ @requires_mongodb_lte_42
31123119 def test_item_frequencies_with_null_embedded (self ):
31133120 class Data (EmbeddedDocument ):
31143121 name = StringField ()
@@ -3137,6 +3144,7 @@ class Person(Document):
31373144 ot = Person .objects .item_frequencies ("extra.tag" , map_reduce = True )
31383145 assert ot == {None : 1.0 , "friend" : 1.0 }
31393146
3147+ @requires_mongodb_lte_42
31403148 def test_item_frequencies_with_0_values (self ):
31413149 class Test (Document ):
31423150 val = IntField ()
@@ -3151,6 +3159,7 @@ class Test(Document):
31513159 ot = Test .objects .item_frequencies ("val" , map_reduce = False )
31523160 assert ot == {0 : 1 }
31533161
3162+ @requires_mongodb_lte_42
31543163 def test_item_frequencies_with_False_values (self ):
31553164 class Test (Document ):
31563165 val = BooleanField ()
@@ -3165,6 +3174,7 @@ class Test(Document):
31653174 ot = Test .objects .item_frequencies ("val" , map_reduce = False )
31663175 assert ot == {False : 1 }
31673176
3177+ @requires_mongodb_lte_42
31683178 def test_item_frequencies_normalize (self ):
31693179 class Test (Document ):
31703180 val = IntField ()
@@ -3551,7 +3561,8 @@ class Book(Document):
35513561 Book .objects .create (title = "The Stories" , authors = [mark_twain , john_tolkien ])
35523562
35533563 authors = Book .objects .distinct ("authors" )
3554- assert authors == [mark_twain , john_tolkien ]
3564+ authors_names = {author .name for author in authors }
3565+ assert authors_names == {mark_twain .name , john_tolkien .name }
35553566
35563567 def test_distinct_ListField_EmbeddedDocumentField_EmbeddedDocumentField (self ):
35573568 class Continent (EmbeddedDocument ):
@@ -3588,7 +3599,8 @@ class Book(Document):
35883599 assert country_list == [scotland , tibet ]
35893600
35903601 continent_list = Book .objects .distinct ("authors.country.continent" )
3591- assert continent_list == [europe , asia ]
3602+ continent_list_names = {c .continent_name for c in continent_list }
3603+ assert continent_list_names == {europe .continent_name , asia .continent_name }
35923604
35933605 def test_distinct_ListField_ReferenceField (self ):
35943606 class Bar (Document ):
0 commit comments