code: def test_OneOfOptionsField():
      @dataclass
      class CustomTestSchema(schema_utils.BaseMarshmallowConfig):
          foo: Union[float, str] = schema_utils.OneOfOptionsField(
              default=0.1,
              description="",
              allow_none=False,
              field_options=[
                  schema_utils.FloatRange(
                      default=0.001, min=0, max=1, allow_none=False
                  ),
                  schema_utils.StringOptions(
                      options=["placeholder"],
                      default="placeholder",
                      allow_none=False,
                  ),
              ],
          )
  
      # Test valid loads:
      assert CustomTestSchema.Schema().load({}).foo == 0.1
      CustomTestSchema().foo == 0.1
  
      # Test invalid loads:
      with pytest.raises(MarshmallowValidationError):
          CustomTestSchema.Schema().load({"foo": None})
      with pytest.raises(MarshmallowValidationError):
          CustomTestSchema.Schema().load({"foo": "test"})
  
      # Reverse the order and allow none (via StringOptions):
      @dataclass
      class CustomTestSchema(schema_utils.BaseMarshmallowConfig):
          foo: Union[None, float, str] = schema_utils.OneOfOptionsField(
              default="placeholder",
              description="",
              field_options=[
                  schema_utils.FloatRange(
                      default=0.001, min=0, max=1, allow_none=False
                  ),
                  schema_utils.StringOptions(
                      options=["placeholder"],
                      default="placeholder",
                      allow_none=False,
                  ),
              ],
              allow_none=True,
          )
  
      # Test valid loads:
      assert CustomTestSchema.Schema().load({}).foo == "placeholder"
      assert CustomTestSchema.Schema().load({"foo": 0.1}).foo == 0.1
      CustomTestSchema().foo == "placeholder"
      CustomTestSchema.Schema().load({"foo": None})
  
      # Test title generation:
      json = schema_utils.unload_jsonschema_from_marshmallow_class(
          CustomTestSchema
      )
      assert json["properties"]["foo"]["title"] == "foo"
      assert (
          json["properties"]["foo"]["oneOf"][0]["title"]
          == "foo_float_option"
      )
  
      # Test invalid loads:
      with pytest.raises(MarshmallowValidationError):
          CustomTestSchema.Schema().load({"foo": "bar"})
  
file_path: ludwig/tests/ludwig/marshmallow/test_fields_misc.py
imports: from typing import Dict, Tuple, Union
  import pytest
  from marshmallow.exceptions import ValidationError
  from marshmallow_dataclass import dataclass
  from ludwig.config_validation.validation import get_validator, validate
  from ludwig.schema import utils
label_desc: Use image node_id 6 for calling a global function with example usage: test_OneOfOptionsField() without return types