

@mock.patch('traceback.format_exception', wraps=fake_format_exception)
def test_frame_stripping(self, mock_format_exception):
    'On assertion error, testify strips head and tail frame which originate from testify.'
    test_result = TestResult((lambda : 'wat'), runner_id='foo!')
    test_result.start()
    root_tb = tb = mock.Mock()
    testify_frames = [True, True, False, True, False, True, True]
    for testify_frame in testify_frames:
        tb.tb_next = mock.Mock()
        tb = tb.tb_next
        f_globals = ({
            '__testify': True,
        } if testify_frame else {
            
        })
        tb.configure_mock(**{
            'tb_frame.f_globals': f_globals,
        })
    tb.tb_next = None
    tb = root_tb.tb_next
    test_result.end_in_failure((AssertionError, 'wat', tb))
    formatted = test_result.format_exception_info()
    assert_equal(formatted, 'Traceback: AssertionError\n')
    mock_format_exception.assert_called_with(AssertionError, 'wat', tb.tb_next.tb_next, 3)

dataset/ETHPy150Open Yelp/Testify/test/test_result_test.py TestResultTestCase.test_frame_stripping/original