@@ -658,10 +658,12 @@ def test_mongos_response(self):
658658 'errmsg' : 'outer' ,
659659 'raw' : {'shard0/host0,host1' : {'ok' : 0 , 'errmsg' : 'inner' }}}
660660
661- with self . assertRaises ( OperationFailure ) as context :
661+ try :
662662 helpers ._check_command_response (error_document , reset = None )
663-
664- self .assertEqual ('inner' , str (context .exception ))
663+ except OperationFailure , exc :
664+ self .assertEqual ('inner' , str (exc ))
665+ else :
666+ self .fail ('OperationFailure not raised' )
665667
666668 # If a shard has no primary and you run a command like dbstats, which
667669 # cannot be run on a secondary, mongos's response includes empty "raw"
@@ -671,21 +673,25 @@ def test_mongos_response(self):
671673 'errmsg' : 'outer' ,
672674 'raw' : {'shard0/host0,host1' : {}}}
673675
674- with self . assertRaises ( OperationFailure ) as context :
676+ try :
675677 helpers ._check_command_response (error_document , reset = None )
676-
677- self .assertEqual ('outer' , str (context .exception ))
678+ except OperationFailure , exc :
679+ self .assertEqual ('outer' , str (exc ))
680+ else :
681+ self .fail ('OperationFailure not raised' )
678682
679683 # Raw error has ok: 0 but no errmsg. Not a known case, but test it.
680684 error_document = {
681685 'ok' : 0 ,
682686 'errmsg' : 'outer' ,
683687 'raw' : {'shard0/host0,host1' : {'ok' : 0 }}}
684688
685- with self . assertRaises ( OperationFailure ) as context :
689+ try :
686690 helpers ._check_command_response (error_document , reset = None )
687-
688- self .assertEqual ('outer' , str (context .exception ))
691+ except OperationFailure , exc :
692+ self .assertEqual ('outer' , str (exc ))
693+ else :
694+ self .fail ('OperationFailure not raised' )
689695
690696 def test_command_read_pref_warning (self ):
691697 ctx = catch_warnings ()
0 commit comments