#NEWLINE# def test_autoincrement( self ) : #NEWLINE# #INDENT# meta = MetaData ( testing . db ) #NEWLINE# try : #NEWLINE# #INDENT# Table ( 'ai_1' , meta , Column ( 'int_y' , Integer , primary_key = True , autoincrement = True ) , Column ( 'int_n' , Integer , DefaultClause ( '0' ) , primary_key = True ) , mysql_engine = 'MyISAM' ) #NEWLINE# Table ( 'ai_2' , meta , Column ( 'int_y' , Integer , primary_key = True , autoincrement = True ) , Column ( 'int_n' , Integer , DefaultClause ( '0' ) , primary_key = True ) , mysql_engine = 'MyISAM' ) #NEWLINE# Table ( 'ai_3' , meta , Column ( 'int_n' , Integer , DefaultClause ( '0' ) , primary_key = True , autoincrement = False ) , Column ( 'int_y' , Integer , primary_key = True , autoincrement = True ) , mysql_engine = 'MyISAM' ) #NEWLINE# Table ( 'ai_4' , meta , Column ( 'int_n' , Integer , DefaultClause ( '0' ) , primary_key = True , autoincrement = False ) , Column ( 'int_n2' , Integer , DefaultClause ( '0' ) , primary_key = True , autoincrement = False ) , mysql_engine = 'MyISAM' ) #NEWLINE# Table ( 'ai_5' , meta , Column ( 'int_y' , Integer , primary_key = True , autoincrement = True ) , Column ( 'int_n' , Integer , DefaultClause ( '0' ) , primary_key = True , autoincrement = False ) , mysql_engine = 'MyISAM' ) #NEWLINE# Table ( 'ai_6' , meta , Column ( 'o1' , String ( 1 ) , DefaultClause ( 'x' ) , primary_key = True ) , Column ( 'int_y' , Integer , primary_key = True , autoincrement = True ) , mysql_engine = 'MyISAM' ) #NEWLINE# Table ( 'ai_7' , meta , Column ( 'o1' , String ( 1 ) , DefaultClause ( 'x' ) , primary_key = True ) , Column ( 'o2' , String ( 1 ) , DefaultClause ( 'x' ) , primary_key = True ) , Column ( 'int_y' , Integer , primary_key = True , autoincrement = True ) , mysql_engine = 'MyISAM' ) #NEWLINE# Table ( 'ai_8' , meta , Column ( 'o1' , String ( 1 ) , DefaultClause ( 'x' ) , primary_key = True ) , Column ( 'o2' , String ( 1 ) , DefaultClause ( 'x' ) , primary_key = True ) , mysql_engine = 'MyISAM' ) #NEWLINE# meta . create_all ( ) #NEWLINE# table_names = [ 'ai_1' , 'ai_2' , 'ai_3' , 'ai_4' , 'ai_5' , 'ai_6' , 'ai_7' , 'ai_8' ] #NEWLINE# mr = MetaData ( testing . db ) #NEWLINE# mr . reflect ( only = table_names ) #NEWLINE# for tbl in [ mr . tables [ name ] for name in table_names ] : #NEWLINE# #INDENT# for c in tbl . c : #NEWLINE# #INDENT# if c . name . startswith ( 'int_y' ) : #NEWLINE# #INDENT# assert c . autoincrement #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if c . name . startswith ( 'int_n' ) : #NEWLINE# #INDENT# assert ( not c . autoincrement ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# tbl . insert ( ) . execute ( ) #NEWLINE# if ( 'int_y' in tbl . c ) : #NEWLINE# #INDENT# assert ( select ( [ tbl . c . int_y ] ) . scalar ( ) == 1 ) #NEWLINE# assert ( list ( tbl . select ( ) . execute ( ) . first ( ) ) . count ( 1 ) == 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert ( 1 not in list ( tbl . select ( ) . execute ( ) . first ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# meta . drop_all ( )