code: def test_enforce_object_with_errors():
      with pytest.raises(
          MlflowException,
          match=r"Expected data to be dictionary, got list",
      ):
          _enforce_object(
              ["some_sentence"],
              Object([Property("a", DataType.string)]),
          )
  
      with pytest.raises(
          MlflowException,
          match=r"Expected obj to be Object, got Property",
      ):
          _enforce_object(
              {"a": "some_sentence"}, Property("a", DataType.string)
          )
  
      obj = Object(
          [
              Property("a", DataType.string),
              Property("b", DataType.string, required=False),
          ]
      )
      with pytest.raises(
          MlflowException, match=r"Missing required properties: {'a'}"
      ):
          _enforce_object({}, obj)
  
      with pytest.raises(
          MlflowException,
          match=r"Invalid properties not defined in the schema found: {'c'}",
      ):
          _enforce_object(
              {"a": "some_sentence", "c": "some_sentence"}, obj
          )
  
      with pytest.raises(
          MlflowException,
          match=r"Failed to enforce schema for key `a`. "
          r"Expected type string, received type int",
      ):
          _enforce_object({"a": 1}, obj)
  
imports: import random
  from collections import namedtuple
  from unittest import mock
  import numpy
  import pytest
  import sklearn.neighbors
  from sklearn import datasets
  import mlflow
  from mlflow import MlflowClient
  from mlflow.entities.model_registry import ModelVersion
  from mlflow.exceptions import MlflowException
  from mlflow.models import add_libraries_to_model
  from mlflow.models.utils import _enforce_array, _enforce_datatype, _enforce_object, _enforce_property, get_model_version_from_model_uri
  from mlflow.types import DataType
  from mlflow.types.schema import Array, Object, Property
label_desc: Use image node_id 11 for calling a global function with example usage: test_enforce_object_with_errors() without return types