code: def test_read_mlflow_creds_file(tmp_path, monkeypatch):
      monkeypatch.delenvs(
          (
              MLFLOW_TRACKING_USERNAME.name,
              MLFLOW_TRACKING_PASSWORD.name,
          ),
          raising=False,
      )
  
      creds_file = tmp_path.joinpath("credentials")
      with mock.patch(
          "mlflow.utils.credentials._get_credentials_path",
          return_value=str(creds_file),
      ):
          # credentials file does not exist
          creds = read_mlflow_creds()
          assert creds.username is None
          assert creds.password is None
  
          # credentials file is empty
          creds = read_mlflow_creds()
          assert creds.username is None
          assert creds.password is None
  
          # password is missing
          creds_file.write_text(
              """
  [mlflow]
  mlflow_tracking_username = username
  """
          )
          creds = read_mlflow_creds()
          assert creds.username == "username"
          assert creds.password is None
  
          # username is missing
          creds_file.write_text(
              """
  [mlflow]
  mlflow_tracking_password = password
  """
          )
          creds = read_mlflow_creds()
          assert creds.username is None
          assert creds.password == "password"
  
          # valid credentials
          creds_file.write_text(
              """
  [mlflow]
  mlflow_tracking_username = username
  mlflow_tracking_password = password
  """
          )
          creds = read_mlflow_creds()
          assert creds is not None
          assert creds.username == "username"
          assert creds.password == "password"
  
file_path: mlflow/tests/utils/test_credentials.py
imports: from unittest import mock
  from unittest.mock import patch
  import pytest
  from mlflow import get_tracking_uri
  from mlflow.environment_variables import MLFLOW_TRACKING_PASSWORD, MLFLOW_TRACKING_USERNAME
  from mlflow.exceptions import MlflowException
  from mlflow.utils.credentials import login, read_mlflow_creds
label_desc: Use image node_id 1 for calling a global function with example usage: test_read_mlflow_creds_file(tmp_path, monkeypatch) without return types