#NEWLINE# @ patch ( 'sys.stdout' , new_callable = StringIO ) #NEWLINE# def test_do_login_session_fail( self , stdout ) : #NEWLINE# #INDENT# registry = Mock ( ) #NEWLINE# registry . prefs = self . prefs #NEWLINE# registry . new_session . side_effect = Exception ( ) #NEWLINE# cli = self . _makeit ( registry ) #NEWLINE# cli . onecmd ( 'login' ) #NEWLINE# self . assertThat ( stdout . getvalue ( ) , Contains ( 'authentication failed' ) )