21
21
import sys
22
22
import time
23
23
import threading
24
- import warnings
25
24
26
25
sys .path [0 :0 ] = ["" ]
27
26
@@ -450,7 +449,6 @@ def test_limit(self):
450
449
break
451
450
self .assertRaises (InvalidOperation , a .limit , 5 )
452
451
453
- @ignore_deprecations # Ignore max without hint.
454
452
def test_max (self ):
455
453
db = self .db
456
454
db .test .drop ()
@@ -460,10 +458,7 @@ def test_max(self):
460
458
db .test .insert_many ([{"j" : j , "k" : j } for j in range (10 )])
461
459
462
460
def find (max_spec , expected_index ):
463
- cursor = db .test .find ().max (max_spec )
464
- if client_context .requires_hint_with_min_max_queries :
465
- cursor = cursor .hint (expected_index )
466
- return cursor
461
+ return db .test .find ().max (max_spec ).hint (expected_index )
467
462
468
463
cursor = find ([("j" , 3 )], j_index )
469
464
self .assertEqual (len (list (cursor )), 3 )
@@ -489,7 +484,6 @@ def find(max_spec, expected_index):
489
484
self .assertRaises (TypeError , db .test .find ().max , 10 )
490
485
self .assertRaises (TypeError , db .test .find ().max , {"j" : 10 })
491
486
492
- @ignore_deprecations # Ignore min without hint.
493
487
def test_min (self ):
494
488
db = self .db
495
489
db .test .drop ()
@@ -499,10 +493,7 @@ def test_min(self):
499
493
db .test .insert_many ([{"j" : j , "k" : j } for j in range (10 )])
500
494
501
495
def find (min_spec , expected_index ):
502
- cursor = db .test .find ().min (min_spec )
503
- if client_context .requires_hint_with_min_max_queries :
504
- cursor = cursor .hint (expected_index )
505
- return cursor
496
+ return db .test .find ().min (min_spec ).hint (expected_index )
506
497
507
498
cursor = find ([("j" , 3 )], j_index )
508
499
self .assertEqual (len (list (cursor )), 7 )
@@ -528,23 +519,15 @@ def find(min_spec, expected_index):
528
519
self .assertRaises (TypeError , db .test .find ().min , 10 )
529
520
self .assertRaises (TypeError , db .test .find ().min , {"j" : 10 })
530
521
531
- @client_context .require_version_max (4 , 1 , - 1 )
532
522
def test_min_max_without_hint (self ):
533
523
coll = self .db .test
534
524
j_index = [("j" , ASCENDING )]
535
525
coll .create_index (j_index )
536
526
537
- with warnings .catch_warnings (record = True ) as warns :
538
- warnings .simplefilter ("default" , DeprecationWarning )
539
- list (coll .find ().min ([("j" , 3 )]))
540
- self .assertIn ('using a min/max query operator' , str (warns [0 ]))
541
- # Ensure the warning is raised with the proper stack level.
542
- del warns [:]
527
+ with self .assertRaises (InvalidOperation ):
543
528
list (coll .find ().min ([("j" , 3 )]))
544
- self .assertIn ('using a min/max query operator' , str (warns [0 ]))
545
- del warns [:]
529
+ with self .assertRaises (InvalidOperation ):
546
530
list (coll .find ().max ([("j" , 3 )]))
547
- self .assertIn ('using a min/max query operator' , str (warns [0 ]))
548
531
549
532
def test_batch_size (self ):
550
533
db = self .db
0 commit comments