code: def test_command_fail_1():
      # Expect that a failing command raises a CommandError in which the return
      # code and the last successful request is caught, and that the command is
      # restarted when called again
      bc = BatchedCommand(
          cmd=py2cmd(
              """
  print("something")
  exit(3)
              """
          )
      )
  
      # Send something to start the process
      first_request = "line one"
      result = bc(first_request)
      assert bc.return_code is None
      assert result == "something"
      with pytest.raises(BatchedCommandError) as exception_info:
          bc("line two")
      assert exception_info.value.code == 3
      assert (
          exception_info.value.last_processed_request == first_request
      )
      assert bc.return_code == 3
  
      # Check for restart
      result = bc(first_request)
      assert result == "something"
      bc.close(return_stderr=False)
  
file_path: datalad/datalad/tests/test_cmd.py
imports: import sys
  import unittest.mock
  from subprocess import TimeoutExpired
  import pytest
  from datalad.cmd import BatchedCommand, readline_rstripped
  from datalad.cmd import BatchedCommandError
  from datalad.runner.tests.utils import py2cmd
  from datalad.tests.utils_pytest import assert_equal, assert_is_none, assert_is_not_none, assert_not_equal, assert_true
label_desc: Use image node_id 9 for calling a global function with example usage: test_command_fail_1() without return types