<s> import sys <EOL> import mock <EOL> from six import moves <EOL> from neutron . tests import base <EOL> from neutron . tests import post_mortem_debug <EOL> class TestTesttoolsExceptionHandler ( base . BaseTestCase ) : <EOL> def test_exception_handler ( self ) : <EOL> try : <EOL> self . assertTrue ( False ) <EOL> except Exception : <EOL> exc_info = sys . exc_info ( ) <EOL> with mock . patch ( '<STR_LIT>' ) as mock_print_exception : <EOL> with mock . patch ( '<STR_LIT>' ) as mock_post_mortem : <EOL> with mock . patch . object ( post_mortem_debug , <EOL> '<STR_LIT>' , <EOL> return_value = mock . Mock ( ) ) : <EOL> post_mortem_debug . get_exception_handler ( '<STR_LIT>' ) ( exc_info ) <EOL> filtered_exc_info = ( exc_info [ <NUM_LIT:0> ] , exc_info [ <NUM_LIT:1> ] , mock . ANY ) <EOL> mock_print_exception . assert_called_once_with ( * filtered_exc_info ) <EOL> mock_post_mortem . assert_called_once_with ( mock . ANY ) <EOL> def test__get_debugger ( self ) : <EOL> def import_mock ( name , * args ) : <EOL> mod_mock = mock . Mock ( ) <EOL> mod_mock . __name__ = name <EOL> mod_mock . post_mortem = mock . Mock ( ) <EOL> return mod_mock <EOL> with mock . patch ( '<STR_LIT>' , <EOL> side_effect = import_mock ) : <EOL> pdb_debugger = post_mortem_debug . _get_debugger ( '<STR_LIT>' ) <EOL> pudb_debugger = post_mortem_debug . _get_debugger ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , pdb_debugger . __name__ ) <EOL> self . assertEqual ( '<STR_LIT>' , pudb_debugger . __name__ ) <EOL> class TestFilteredTraceback ( base . BaseTestCase ) : <EOL> def test_filter_traceback ( self ) : <EOL> tb1 = mock . Mock ( ) <EOL> tb2 = mock . Mock ( ) <EOL> tb1 . tb_next = tb2 <EOL> tb2 . tb_next = None <EOL> ftb1 = post_mortem_debug . FilteredTraceback ( tb1 , tb2 ) <EOL> for attr in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> attr_name = '<STR_LIT>' % attr <EOL> self . assertEqual ( getattr ( tb1 , attr_name , None ) , <EOL> getattr ( ftb1 , attr_name , None ) ) <EOL> self . assertIsNone ( ftb1 . tb_next ) <EOL> class TestGetIgnoredTraceback ( base . BaseTestCase ) : <EOL> def _test_get_ignored_traceback ( self , ignored_bit_array , expected ) : <EOL> root_tb = mock . Mock ( ) <EOL> tb = root_tb <EOL> tracebacks = [ tb ] <EOL> for x in moves . range ( len ( ignored_bit_array ) - <NUM_LIT:1> ) : <EOL> tb . tb_next = mock . Mock ( ) <EOL> tb = tb . tb_next <EOL> tracebacks . append ( tb ) <EOL> tb . tb_next = None <EOL> tb = root_tb <EOL> for ignored in ignored_bit_array : <EOL> if ignored : <EOL> tb . tb_frame . f_globals = [ '<STR_LIT>' ] <EOL> else : <EOL> tb . tb_frame . f_globals = [ ] <EOL> tb = tb . tb_next <EOL> actual = post_mortem_debug . get_ignored_traceback ( root_tb ) <EOL> if expected is not None : <EOL> expected = tracebacks [ expected ] <EOL> self . assertEqual ( expected , actual ) <EOL> def test_no_ignored_tracebacks ( self ) : <EOL> self . _test_get_ignored_traceback ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , None ) <EOL> def test_single_member_trailing_chain ( self ) : <EOL> self . _test_get_ignored_traceback ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:2> ) <EOL> def test_two_member_trailing_chain ( self ) : <EOL> self . _test_get_ignored_traceback ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT:1> ) <EOL> def test_first_traceback_ignored ( self ) : <EOL> self . _test_get_ignored_traceback ( [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ] , None ) <EOL> def test_middle_traceback_ignored ( self ) : <EOL> self . _test_get_ignored_traceback ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> ] , None ) </s>
