code: def test_to_yaml(tmp_path):
      yaml_path = tmp_path / "python_env.yaml"
      _PythonEnv("3.8.15", ["a"], ["b"]).to_yaml(yaml_path)
      expected_content = """
  python: 3.8.15
  build_dependencies:
  - a
  dependencies:
  - b
  """.lstrip()
      assert yaml_path.read_text() == expected_content
  
file_path: mlflow/tests/utils/test_python_env.py
imports: from unittest import mock
  import pytest
  from mlflow.utils import PYTHON_VERSION
  from mlflow.utils.environment import _PythonEnv
label_desc: Use image node_id 2 for calling a global function with example usage: test_to_yaml(tmp_path) without return types