@@ -829,7 +829,6 @@ def test_count_with_hint(self):
829829 self .assertEqual (2 , collection .find ().hint ("x_1" ).count ())
830830 self .assertEqual (2 , collection .find ().hint ([("x" , 1 )]).count ())
831831
832- @client_context .require_version_max (4 , 3 , 2 ) # PYTHON-2130
833832 @ignore_deprecations
834833 def test_where (self ):
835834 db = self .db
@@ -845,8 +844,20 @@ def test_where(self):
845844 self .assertEqual (3 , len (list (db .test .find ().where ('this.x < 3' ))))
846845 self .assertEqual (3 ,
847846 len (list (db .test .find ().where (Code ('this.x < 3' )))))
848- self .assertEqual (3 , len (list (db .test .find ().where (Code ('this.x < i' ,
849- {"i" : 3 })))))
847+
848+ code_with_scope = Code ('this.x < i' , {"i" : 3 })
849+ if client_context .version .at_least (4 , 3 , 3 ):
850+ # MongoDB 4.4 removed support for Code with scope.
851+ with self .assertRaises (OperationFailure ):
852+ list (db .test .find ().where (code_with_scope ))
853+
854+ code_with_empty_scope = Code ('this.x < 3' , {})
855+ with self .assertRaises (OperationFailure ):
856+ list (db .test .find ().where (code_with_empty_scope ))
857+ else :
858+ self .assertEqual (
859+ 3 , len (list (db .test .find ().where (code_with_scope ))))
860+
850861 self .assertEqual (10 , len (list (db .test .find ())))
851862
852863 self .assertEqual (3 , db .test .find ().where ('this.x < 3' ).count ())
0 commit comments