def METHOD_NAME(running_test: bool, monkeypatch, caplog):
    """
    This test case checks that unserializable log messages no longer make
    the CRUD handler hang in production and that an exception is raised when the
    RUNNING_TEST variable is set to True.
    """
    import inmanta
    monkeypatch.setattr(inmanta, "RUNNING_TESTS", running_test)
    @resource(name="aa::Aa", id_attribute="aa", agent="aa")
    class TestResource(PurgeableResource):
        fields = ("value",)
    class DummyCrud(CRUDHandler[TestResource]):
        def __init__(self):
            self.updated = False
        def read_resource(self, ctx: HandlerContext, resource: TestResource) -> None:
            resource.value = "b"
            unserializable_set = {"b"}
            ctx.debug(msg="Unserializable kwargs: ", kwargs={"unserializable": unserializable_set})
        def update_resource(self, ctx: HandlerContext, changes: Dict[str, Dict[str, Any]], resource: TestResource) -> None:
            self.updated = True
    res = TestResource(Id(entity_type="aa::Aa", agent_name="aa", attribute="aa", attribute_value="aa", version=1))
    res.value = "a"
    res.purged = False
    ctx = HandlerContext(res, dry_run=False)
    handler = DummyCrud()
    if running_test:
        handler.execute(ctx, res, dry_run=False)
        error_message = "Failed to serialize argument for log message"
        assert ctx.status is ResourceState.failed
        assert error_message in caplog.text
    else:
        handler.execute(ctx, res, dry_run=False)
        assert ctx.status is ResourceState.deployed
        assert handler.updated