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"
def test_warning_on_unwrap_of_broken_object( stop: Optional[Callable[[object], object]]) -> None: 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) # type: ignore[arg-type] assert inspect.unwrap.__module__ == "inspect"