@pytest.mark.parametrize('stop', [None, _is_mocked, (lambda f: None), (lambda f: False), (lambda f: True)])
def test_warning_on_unwrap_of_broken_object(stop):
    bad_instance = Broken()
    assert (inspect.unwrap.__module__ == 'inspect')
    with _patch_unwrap_mock_aware():
        assert (inspect.unwrap.__module__ != 'inspect')
        with pytest.warns(pytest.PytestWarning, match='^Got KeyError.* when unwrapping'):
            with pytest.raises(KeyError):
                inspect.unwrap(bad_instance, stop=stop)
    assert (inspect.unwrap.__module__ == 'inspect')
@pytest.mark.parametrize('stop', [None, _is_mocked, (lambda f: None), (lambda f: False), (lambda f: True)])
def test_warning_on_unwrap_of_broken_object(stop):
    bad_instance = Broken()
    assert (inspect.unwrap.__module__ == 'inspect')
    with _patch_unwrap_mock_aware():
        assert (inspect.unwrap.__module__ != 'inspect')
        with pytest.warns(pytest.PytestWarning, match='^Got KeyError.* when unwrapping'):
            with pytest.raises(KeyError):
                inspect.unwrap(bad_instance, stop=stop)
    assert (inspect.unwrap.__module__ == 'inspect')