code: def test_save_mocked(
      mocker, dot, filename="nonfilename", directory="nondirectory"
  ):
      mock_makedirs = mocker.patch("os.makedirs", autospec=True)
      mock_open = mocker.patch("builtins.open", mocker.mock_open())
  
      with pytest.deprecated_call():
          assert dot.save(filename, directory) == dot.filepath
  
      assert dot.filename == filename
      assert dot.directory == directory
      mock_makedirs.assert_called_once_with(
          dot.directory, 0o777, exist_ok=True
      )
      mock_open.assert_called_once_with(
          dot.filepath, "w", encoding=dot.encoding
      )
      expected_calls = (
          [mocker.call(dot.source)]
          if type(dot).__name__ == "Source"
          else [mocker.call(mocker.ANY), mocker.call("}\n")]
      )
      assert (
          mock_open.return_value.write.call_args_list == expected_calls
      )
  
imports: import locale
  import pathlib
  import re
  import subprocess
  import pytest
  import graphviz
  import _common
label_desc: Use image node_id 14 for calling a global function with example usage: test_save_mocked(mocker, dot, filename, directory) without return types