code: def test_getopt(self):
      # note: the empty string between '-a' and '--beta' is significant:
      # it simulates an empty string option argument ('-a ""') on the
      # command line.
      cmdline = [
          "-a",
          "1",
          "-b",
          "--alpha=2",
          "--beta",
          "-a",
          "3",
          "-a",
          "",
          "--beta",
          "arg1",
          "arg2",
      ]
  
      opts, args = getopt.getopt(cmdline, "a:b", ["alpha=", "beta"])
      self.assertEqual(
          opts,
          [
              ("-a", "1"),
              ("-b", ""),
              ("--alpha", "2"),
              ("--beta", ""),
              ("-a", "3"),
              ("-a", ""),
              ("--beta", ""),
          ],
      )
      # Note ambiguity of ('-b', '') and ('-a', '') above. This must be
      # accounted for in the code that calls getopt().
      self.assertEqual(args, ["arg1", "arg2"])
  
      self.assertError(getopt.getopt, cmdline, "a:b", ["alpha", "beta"])
  
file_path: cpython/Lib/test/test_getopt.py
imports: from test.support.os_helper import EnvironmentVarGuard
  import doctest
  import unittest
  import getopt
label_desc: Use image node_id 7 for calling the GetoptTests obj's underlying member method code with example usage: obj.test_getopt() without return types