#NEWLINE# @ testing . crashes ( 'sqlite' , ':memory: connection not suitable here' ) #NEWLINE# def test_orm_many_engines( self ) : #NEWLINE# #INDENT# metadata = MetaData ( self . engine ) #NEWLINE# table1 = Table ( 'mytable' , metadata , Column ( 'col1' , Integer , primary_key = True , test_needs_autoincrement = True ) , Column ( 'col2' , String ( 30 ) ) ) #NEWLINE# table2 = Table ( 'mytable2' , metadata , Column ( 'col1' , Integer , primary_key = True , test_needs_autoincrement = True ) , Column ( 'col2' , String ( 30 ) ) , Column ( 'col3' , Integer , ForeignKey ( 'mytable.col1' ) ) ) #NEWLINE# metadata . create_all ( ) #NEWLINE# m1 = mapper ( A , table1 , properties = { #NEWLINE# #INDENT# 'bs' : relationship ( B , cascade = 'all, delete' , order_by = table2 . c . col1 ) , #NEWLINE# #UNINDENT# } , _compiled_cache_size = 10 ) #NEWLINE# m2 = mapper ( B , table2 , _compiled_cache_size = 10 ) #NEWLINE# m3 = mapper ( A , table1 , non_primary = True ) #NEWLINE# @ profile_memory ( ) #NEWLINE# def go( ) : #NEWLINE# #INDENT# engine = engines . testing_engine ( options = { #NEWLINE# #INDENT# 'logging_name' : 'FOO' , #NEWLINE# 'pool_logging_name' : 'BAR' , #NEWLINE# 'use_reaper' : False , #NEWLINE# #UNINDENT# } ) #NEWLINE# sess = create_session ( bind = engine ) #NEWLINE# a1 = A ( col2 = 'a1' ) #NEWLINE# a2 = A ( col2 = 'a2' ) #NEWLINE# a3 = A ( col2 = 'a3' ) #NEWLINE# a1 . bs . append ( B ( col2 = 'b1' ) ) #NEWLINE# a1 . bs . append ( B ( col2 = 'b2' ) ) #NEWLINE# a3 . bs . append ( B ( col2 = 'b3' ) ) #NEWLINE# for x in [ a1 , a2 , a3 ] : #NEWLINE# #INDENT# sess . add ( x ) #NEWLINE# #UNINDENT# sess . flush ( ) #NEWLINE# sess . expunge_all ( ) #NEWLINE# alist = sess . query ( A ) . order_by ( A . col1 ) . all ( ) #NEWLINE# eq_ ( [ A ( col2 = 'a1' , bs = [ B ( col2 = 'b1' ) , B ( col2 = 'b2' ) ] ) , A ( col2 = 'a2' , bs = [ ] ) , A ( col2 = 'a3' , bs = [ B ( col2 = 'b3' ) ] ) ] , alist ) #NEWLINE# for a in alist : #NEWLINE# #INDENT# sess . delete ( a ) #NEWLINE# #UNINDENT# sess . flush ( ) #NEWLINE# sess . close ( ) #NEWLINE# engine . dispose ( ) #NEWLINE# #UNINDENT# go ( ) #NEWLINE# metadata . drop_all ( ) #NEWLINE# del m1 , m2 , m3 #NEWLINE# assert_no_mappers ( )