docstr: Check compatibility with different pydantic versions.
docstr_tok: ["Check","compatibility","with","different","pydantic","versions","."]
code: def test_pydantic_version_compatibility(self, use_v1_patch: bool):
      """Check compatibility with different pydantic versions."""
  
      if use_v1_patch:
          try:
              # Only runs if installed pydantic version is >=2.5.0
              from pydantic.v1 import BaseModel
          except ImportError:
              return
      else:
          from pydantic import BaseModel
  
      cat_dict = {"color": "orange", "age": 10}
  
      class Cat(BaseModel):
          color: str
          age: int
  
      def build(args: Cat):
          """Builder with Pydantic model type hint."""
  
          assert isinstance(args, Cat), f"args type: {type(args)}"
          assert args.color == cat_dict["color"]
          assert args.age == cat_dict["age"]
          return self.A.bind(
              f"My {args.color} cat is {args.age} years old."
          )
  
      app = call_app_builder_with_args_if_necessary(build, cat_dict)
      assert isinstance(app, Application)
  
imports: import asyncio
  import os
  import sys
  from typing import Dict, Optional
  import pytest
  import requests
  import starlette.responses
  from fastapi import FastAPI
  import ray
  from ray import serve
  from ray._private.pydantic_compat import BaseModel, ValidationError
  from ray._private.test_utils import SignalActor, wait_for_condition
  from ray.serve._private.api import call_app_builder_with_args_if_necessary
  from ray.serve._private.common import DeploymentID
  from ray.serve._private.constants import SERVE_DEFAULT_APP_NAME
  from ray.serve.deployment import Application
  from ray.serve.exceptions import RayServeException
  from ray.serve.handle import DeploymentHandle, RayServeHandle
label_desc: Use image node_id 9 for calling the TestAppBuilder obj's underlying member method code with example usage: obj.test_pydantic_version_compatibility(use_v1_patch) and returns: self