code: def make_writeable_mocks():
      """Produce some mocks which we will use for testing the `write_image()` function.
  
      These mocks should be passed as the `file=` argument to `write_image()`.
  
      The tests should verify that the method specified in the `active_write_function`
      attribute is called once, and that scope.transform is called with the `format=`
      argument specified by the `.expected_format` attribute.
  
      In total we provide two mocks: one for a writable file descriptor, and other for a
      pathlib.Path object.
      """
  
      # Part 1: A mock for a file descriptor
      # ------------------------------------
      mock_file_descriptor = Mock()
  
      # A file descriptor has no write_bytes method, unlike a pathlib Path.
      del mock_file_descriptor.write_bytes
  
      # The expected write method for a file descriptor is .write
      mock_file_descriptor.active_write_function = (
          mock_file_descriptor.write
      )
  
      # Since there is no filename, there should be no format detected.
      mock_file_descriptor.expected_format = None
  
      # Part 2: A mock for a pathlib path
      # ---------------------------------
      mock_pathlib_path = Mock(spec=Path)
  
      # A pathlib Path object has no write method, unlike a file descriptor.
      del mock_pathlib_path.write
  
      # The expected write method for a pathlib Path is .write_bytes
      mock_pathlib_path.active_write_function = (
          mock_pathlib_path.write_bytes
      )
  
      # Mock a path with PNG suffix
      mock_pathlib_path.suffix = ".png"
      mock_pathlib_path.expected_format = "png"
  
      return mock_file_descriptor, mock_pathlib_path
  
file_path: plotly.py/packages/python/plotly/plotly/tests/test_optional/test_kaleido/test_kaleido.py
imports: import plotly.io
  import plotly.io.kaleido
  from contextlib import contextmanager
  from io import BytesIO
  from pathlib import Path
  from unittest.mock import Mock
label_desc: Use image node_id 1 for calling a global function with example usage: make_writeable_mocks() and returns: mock_file_descriptor,  mock_pathlib_path