#NEWLINE# def test_continue_on_error( self ) : #NEWLINE# #INDENT# db = self . db #NEWLINE# db . drop_collection ( 'test_continue_on_error' ) #NEWLINE# collection = db . test_continue_on_error #NEWLINE# oid = collection . insert ( { #NEWLINE# #INDENT# 'one' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( 1 , collection . count ( ) ) #NEWLINE# docs = [ ] #NEWLINE# docs . append ( { #NEWLINE# #INDENT# '_id' : oid , #NEWLINE# 'two' : 2 , #NEWLINE# #UNINDENT# } ) #NEWLINE# docs . append ( { #NEWLINE# #INDENT# 'three' : 3 , #NEWLINE# #UNINDENT# } ) #NEWLINE# docs . append ( { #NEWLINE# #INDENT# 'four' : 4 , #NEWLINE# #UNINDENT# } ) #NEWLINE# docs . append ( { #NEWLINE# #INDENT# 'five' : 5 , #NEWLINE# #UNINDENT# } ) #NEWLINE# with self . assertRaises ( DuplicateKeyError ) : #NEWLINE# #INDENT# collection . insert ( docs , manipulate = False ) #NEWLINE# #UNINDENT# self . assertEqual ( 1 , collection . count ( ) ) #NEWLINE# with self . assertRaises ( DuplicateKeyError ) : #NEWLINE# #INDENT# collection . insert ( self , manipulate = False , continue_on_error = True ) #NEWLINE# #UNINDENT# self . assertEqual ( 4 , collection . count ( ) ) #NEWLINE# db . drop_collection ( 'test_continue_on_error' ) #NEWLINE# oid = collection . insert ( { #NEWLINE# #INDENT# '_id' : oid , #NEWLINE# 'one' : 1 , #NEWLINE# #UNINDENT# } , w = 0 ) #NEWLINE# wait_until ( ( lambda : ( 1 == collection . count ( ) ) ) , 'insert 1 document' ) #NEWLINE# docs [ 0 ] . pop ( '_id' ) #NEWLINE# docs [ 2 ] [ '_id' ] = oid #NEWLINE# with self . assertRaises ( DuplicateKeyError ) : #NEWLINE# #INDENT# collection . insert ( docs , manipulate = False ) #NEWLINE# #UNINDENT# self . assertEqual ( 3 , collection . count ( ) ) #NEWLINE# collection . insert ( docs , manipulate = False , continue_on_error = True , w = 0 ) #NEWLINE# wait_until ( ( lambda : ( 6 == collection . count ( ) ) ) , 'insert 3 documents' )