code: def test_pipe_lines_mocked(
      capsys, mock_popen, quiet, input_encoding="ascii"
  ):
      proc = mock_popen.return_value
      proc.configure_mock(
          args=_common.EXPECTED_DOT_BINARY,
          returncode=0,
          stdin=io.BytesIO(),
          stdout=io.BytesIO(b"stdout"),
          stderr=io.BytesIO(b"stderr"),
      )
      proc.communicate.side_effect = lambda: (
          proc.stdout.read(),
          proc.stderr.read(),
      )
  
      assert (
          graphviz.pipe_lines(
              "dot",
              "png",
              iter(["nongraph\n"]),
              input_encoding=input_encoding,
              quiet=quiet,
          )
          == b"stdout"
      )
  
      assert proc.stdin.getvalue() == b"nongraph\n"
  
      mock_popen.assert_called_once_with(
          [_common.EXPECTED_DOT_BINARY, "-Kdot", "-Tpng"],
          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 6 for calling a global function with example usage: test_pipe_lines_mocked(capsys, mock_popen, quiet, input_encoding) without return types