code: def test_render_mocked(
      capsys, mock_run, quiet, directory, filepath="nonfilepath"
  ):
      mock_run.return_value = subprocess.CompletedProcess(
          _common.INVALID_CMD,
          returncode=0,
          stdout="stdout",
          stderr="stderr",
      )
  
      if directory is not None:
          filepath = os.path.join(directory, filepath)
  
      result = graphviz.render(
          "dot", "pdf", filepath, neato_no_op=True, quiet=quiet
      )
  
      assert result == f"{filepath}.pdf"
  
      mock_run.assert_called_once_with(
          [
              _common.EXPECTED_DOT_BINARY,
              "-Kdot",
              "-Tpdf",
              "-n1",
              "-O",
              "nonfilepath",
          ],
          capture_output=True,
          cwd=_tools.promote_pathlike(directory),
          startupinfo=_common.StartupinfoMatcher(),
      )
      assert capsys.readouterr() == ("", "" if quiet else "stderr")
  
imports: import pathlib
  import os
  import shutil
  import subprocess
  import pytest
  import graphviz
  from graphviz import _tools
  from graphviz.backend import rendering
  import _common
label_desc: Use image node_id 7 for calling a global function with example usage: test_render_mocked(capsys, mock_run, quiet, directory, filepath) without return types