code: def test_command_fail_2():
      # Expect that a failing command raises a BatchedCommandError in which the
      # return code and the last successful request is caught. In this case the
      # last successful request should be None.
      bc = BatchedCommand(
          cmd=py2cmd(
              """
  print(a*b)
              """
          )
      )
  
      # Send something to start the process
      first_request = "line one"
      with pytest.raises(BatchedCommandError) as exception_info:
          _ = bc(first_request)
      assert exception_info.value.code == 1
      assert exception_info.value.last_processed_request is None
      assert bc.return_code == 1
      assert bc.last_request is None
      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 10 for calling a global function with example usage: test_command_fail_2() without return types