code: def test_pipe_lines_string_mocked(
      capsys, mock_popen, quiet, encoding="ascii"
  ):
      proc = mock_popen.return_value
      proc.configure_mock(
          args=_common.INVALID_CMD,
          returncode=0,
          stdin=io.StringIO(),
          stdout=io.StringIO("stdout"),
          stderr=io.StringIO("stderr"),
      )
      proc.communicate.side_effect = lambda: (
          proc.stdout.read(),
          proc.stderr.read(),
      )
  
      assert (
          graphviz.pipe_lines_string(
              "dot",
              "png",
              iter(["nongraph\n"]),
              encoding=encoding,
              quiet=quiet,
          )
          == "stdout"
      )
  
      assert proc.stdin.getvalue() == "nongraph\n"
  
      mock_popen.assert_called_once_with(
          [_common.EXPECTED_DOT_BINARY, "-Kdot", "-Tpng"],
          encoding=encoding,
          stdin=subprocess.PIPE,
          stdout=subprocess.PIPE,
          stderr=subprocess.PIPE,
          startupinfo=_common.StartupinfoMatcher(),
      )
      assert capsys.readouterr() == ("", "" if quiet else "stderr")
  
file_path: graphviz/tests/backend/test_piping.py
imports: import io
  import re
  import subprocess
  import pytest
  import graphviz
  import _common
label_desc: Use image node_id 7 for calling a global function with example usage: test_pipe_lines_string_mocked(capsys, mock_popen, quiet, encoding) without return types