@@ -486,15 +486,16 @@ def _get_expected_resume_token(self, stream, listener, previous_change=None):
486
486
return response ["cursor" ]["postBatchResumeToken" ]
487
487
488
488
@no_type_check
489
- def _test_raises_error_on_missing_id (self , expected_exception , expected_exception2 ):
489
+ def _test_raises_error_on_missing_id (self , expected_exception ):
490
490
"""ChangeStream will raise an exception if the server response is
491
491
missing the resume token.
492
492
"""
493
493
with self .change_stream ([{"$project" : {"_id" : 0 }}]) as change_stream :
494
494
self .watched_collection ().insert_one ({})
495
495
with self .assertRaises (expected_exception ):
496
496
next (change_stream )
497
- with self .assertRaises (expected_exception2 ):
497
+ # The cursor should now be closed.
498
+ with self .assertRaises (StopIteration ):
498
499
next (change_stream )
499
500
500
501
@no_type_check
@@ -526,14 +527,14 @@ def test_update_resume_token_legacy(self):
526
527
# Prose test no. 2
527
528
@client_context .require_version_min (4 , 1 , 8 )
528
529
def test_raises_error_on_missing_id_418plus (self ):
529
- # Server returns an error on 4.1.8+, subsequent next() resumes and gets the same error.
530
- self ._test_raises_error_on_missing_id (OperationFailure , OperationFailure )
530
+ # Server returns an error on 4.1.8+
531
+ self ._test_raises_error_on_missing_id (OperationFailure )
531
532
532
533
# Prose test no. 2
533
534
@client_context .require_version_max (4 , 1 , 8 )
534
535
def test_raises_error_on_missing_id_418minus (self ):
535
- # PyMongo raises an error, closes the cursor, subsequent next() raises StopIteration.
536
- self ._test_raises_error_on_missing_id (InvalidOperation , StopIteration )
536
+ # PyMongo raises an error
537
+ self ._test_raises_error_on_missing_id (InvalidOperation )
537
538
538
539
# Prose test no. 3
539
540
@no_type_check
0 commit comments