code: def test_interface():
      di = Demo()
  
      import argparse
  
      parser = argparse.ArgumentParser()
  
      from datalad.cli.parser import setup_parser_for_interface
  
      setup_parser_for_interface(parser, di)
      with swallow_outputs() as cmo:
          assert_equal(parser.print_help(), None)
          assert cmo.out
          assert_equal(cmo.err, "")
      args = parser.parse_args(
          ["42", "11", "1", "2", "--demoarg", "23"]
      )
      assert_is(args.demoarg, 23)
      assert_equal(args.demoposarg, [42, 11])
      assert_equal(args.demooptposarg1, 1)
      assert_equal(args.demooptposarg2, 2)
  
      # wrong type
      with swallow_outputs() as cmo:
          assert_raises(
              SystemExit, parser.parse_args, ["--demoarg", "abc"]
          )
          # that is what we dump upon folks atm. TODO: improve reporting of illspecified options
          assert_re_in(
              ".*invalid constraint:int value:.*", cmo.err, re.DOTALL
          )
  
      # missing argument to option
      with swallow_outputs() as cmo:
          assert_raises(SystemExit, parser.parse_args, ["--demoarg"])
          assert_re_in(
              ".*--demoarg: expected one argument", cmo.err, re.DOTALL
          )
  
      # missing positional argument
      with swallow_outputs() as cmo:
          assert_raises(SystemExit, parser.parse_args, [""])
          # PY2|PY3
          assert_re_in(
              ".*error: (too few arguments|the following arguments are required: demoposarg)",
              cmo.err,
              re.DOTALL,
          )
  
file_path: datalad/datalad/tests/test_interface.py
imports: import re
  from datalad.interface.base import Interface, get_api_name
  from datalad.support import constraints
  from datalad.support.param import Parameter
  from datalad.tests.utils_pytest import assert_equal, assert_in, assert_is, assert_raises, assert_re_in, assert_true, swallow_outputs
label_desc: Use image node_id 2 for calling a global function with example usage: test_interface() without return types