code: def test_post_pipe_callbacks() -> None:
      # Expect that the process_exited and connection_lost callbacks
      # are also called in a GeneratorMixIn protocol
      class TestPostPipeProtocol(GeneratorMixIn, StdOutErrCapture):
          def __init__(self) -> None:
              GeneratorMixIn.__init__(self)
              StdOutErrCapture.__init__(self)
  
          def process_exited(self) -> None:
              self.send_result(1)
              self.send_result(2)
  
          def connection_lost(
              self, exc: Optional[BaseException]
          ) -> None:
              self.send_result(3)
              self.send_result(4)
  
      runner = WitlessRunner()
      results = list(
          runner.run(cmd=["echo", "a"], protocol=TestPostPipeProtocol)
      )
      assert_equal(results, [1, 2, 3, 4])
  
imports: from __future__ import annotations
  import sys
  from queue import Queue
  from typing import Any, Optional
  from datalad.runner.coreprotocols import NoCapture, StdOutErrCapture
  from datalad.runner.nonasyncrunner import _ResultGenerator, run_command
  from datalad.runner.protocol import GeneratorMixIn
  from datalad.tests.utils_pytest import assert_equal, assert_raises
  from ..exception import CommandError
  from ..runner import WitlessRunner
  from .utils import py2cmd
label_desc: Use image node_id 3 for calling a global function with example usage: test_post_pipe_callbacks() without return types