#NEWLINE# def test_autodetects( self , monkeypatch , cli ) : #NEWLINE# #INDENT# autodetect = pretend . call_recorder ( ( lambda : 'plain' ) ) #NEWLINE# monkeypatch . setattr ( shell , 'autodetect' , autodetect ) #NEWLINE# session = pretend . stub ( ) #NEWLINE# session_cls = pretend . call_recorder ( ( lambda bind : session ) ) #NEWLINE# monkeypatch . setattr ( db , 'Session' , session_cls ) #NEWLINE# plain = pretend . call_recorder ( ( lambda **kw : None ) ) #NEWLINE# monkeypatch . setattr ( shell , 'plain' , plain ) #NEWLINE# engine = pretend . stub ( ) #NEWLINE# config = pretend . stub ( registry = { #NEWLINE# #INDENT# 'sqlalchemy.engine' : engine , #NEWLINE# #UNINDENT# } ) #NEWLINE# result = cli . invoke ( shell . shell , obj = config ) #NEWLINE# assert ( result . exit_code == 0 ) #NEWLINE# assert ( autodetect . calls == [ pretend . call ( ) ] ) #NEWLINE# assert ( session_cls . calls == [ pretend . call ( bind = engine ) ] ) #NEWLINE# assert ( plain . calls == [ pretend . call ( config = config , db = session ) ] )