code: def test_exit_code():
      # will relay actual exit code on CommandError
      cmd = ["datalad", "sshrun", "datalad-test", "exit 42"]
      with assert_raises(SystemExit) as cme:
          # running nosetests without -s
          if isinstance(sys.stdout, StringIO):  # pragma: no cover
              with swallow_outputs():  # need to give smth with .fileno ;)
                  main(cmd)
          else:
              # to test both scenarios
              main(cmd)
      assert_equal(cme.value.code, 42)
  
file_path: datalad/datalad/support/tests/test_sshrun.py
imports: import sys
  from io import StringIO, UnsupportedOperation
  import pytest
  from unittest.mock import patch
  from datalad.api import sshrun
  from datalad.cli.main import main
  from datalad.cmd import StdOutCapture, WitlessRunner
  from datalad.tests.utils_pytest import SkipTest, assert_equal, assert_raises, skip_if_on_windows, skip_ssh, swallow_outputs, with_tempfile
label_desc: Use image node_id 1 for calling a global function with example usage: test_exit_code() without return types