#NEWLINE# def test_truncation( self ) : #NEWLINE# #INDENT# columndefs = ( 'col1 INT' , 'col2 VARCHAR(255)' ) #NEWLINE# def generator( row , col ) : #NEWLINE# #INDENT# if ( col == 0 ) : #NEWLINE# #INDENT# return row #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( ( '%i' % ( row % 10 ) ) * ( ( 255 - ( self . rows / 2 ) ) + row ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . create_table ( columndefs ) #NEWLINE# insert_statement = ( 'INSERT INTO %s VALUES (%s)' % ( self . table , ',' . join ( ( [ '%s' ] * len ( columndefs ) ) ) ) ) #NEWLINE# try : #NEWLINE# #INDENT# self . cursor . execute ( insert_statement , ( 0 , ( '0' * 256 ) ) ) #NEWLINE# #UNINDENT# except self . connection . DataError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . fail ( 'Over-long column did not generate warnings/exception with single insert' ) #NEWLINE# #UNINDENT# self . connection . rollback ( ) #NEWLINE# try : #NEWLINE# #INDENT# for i in range ( self . rows ) : #NEWLINE# #INDENT# data = [ ] #NEWLINE# for j in range ( len ( columndefs ) ) : #NEWLINE# #INDENT# data . append ( generator ( i , j ) ) #NEWLINE# #UNINDENT# self . cursor . execute ( insert_statement , tuple ( data ) ) #NEWLINE# #UNINDENT# #UNINDENT# except self . connection . DataError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . fail ( 'Over-long columns did not generate warnings/exception with execute()' ) #NEWLINE# #UNINDENT# self . connection . rollback ( ) #NEWLINE# try : #NEWLINE# #INDENT# data = [ [ generator ( i , j ) for j in range ( len ( columndefs ) ) ] for i in range ( self . rows ) ] #NEWLINE# self . cursor . executemany ( insert_statement , data ) #NEWLINE# #UNINDENT# except self . connection . DataError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . fail ( 'Over-long columns did not generate warnings/exception with executemany()' ) #NEWLINE# #UNINDENT# self . connection . rollback ( ) #NEWLINE# self . cursor . execute ( ( 'drop table %s' % self . table ) )