#NEWLINE# def test_atomic_prevents_queries_in_broken_transaction( self ) : #NEWLINE# #INDENT# r1 = Reporter . objects . create ( first_name = 'Archibald' , last_name = 'Haddock' ) #NEWLINE# with transaction . atomic ( ) : #NEWLINE# #INDENT# r2 = Reporter ( first_name = 'Cuthbert' , last_name = 'Calculus' , id = r1 . id ) #NEWLINE# with self . assertRaises ( IntegrityError ) : #NEWLINE# #INDENT# r2 . save ( force_insert = True ) #NEWLINE# #UNINDENT# with self . assertRaises ( transaction . TransactionManagementError ) : #NEWLINE# #INDENT# r2 . save ( force_update = True ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( Reporter . objects . get ( pk = r2 . pk ) . last_name , 'Haddock' )