Lines Matching +full:test +full:- +full:beta
2 # David Goodger <dgoodger@bigfoot.com> 2000-08-19
4 from test.support import verbose, run_doctest
5 from test.support.os_helper import EnvironmentVarGuard
45 self.assertEqual(opts, [('-a', '')])
49 self.assertEqual(opts, [('-a', '1')])
53 #self.assertEqual(opts, [('-a', '1')])
57 self.assertEqual(opts, [('-a', '1')])
61 self.assertEqual(opts, [('-a', '1')])
69 self.assertEqual(opts, [('--abc', '')])
73 self.assertEqual(opts, [('--abc', '1')])
77 self.assertEqual(opts, [('--abcd', '1')])
81 self.assertEqual(opts, [('--abc', '')])
84 # Much like the preceding, except with a non-alpha character ("-") in
87 opts, args = getopt.do_longs([], 'foo=42', ['foo-bar', 'foo=',], [])
88 self.assertEqual(opts, [('--foo', '42')])
95 # note: the empty string between '-a' and '--beta' is significant:
96 # it simulates an empty string option argument ('-a ""') on the
98 cmdline = ['-a', '1', '-b', '--alpha=2', '--beta', '-a', '3', '-a',
99 '', '--beta', 'arg1', 'arg2']
101 opts, args = getopt.getopt(cmdline, 'a:b', ['alpha=', 'beta'])
102 self.assertEqual(opts, [('-a', '1'), ('-b', ''),
103 ('--alpha', '2'), ('--beta', ''),
104 ('-a', '3'), ('-a', ''), ('--beta', '')])
105 # Note ambiguity of ('-b', '') and ('-a', '') above. This must be
109 self.assertError(getopt.getopt, cmdline, 'a:b', ['alpha', 'beta'])
112 # Test handling of GNU style scanning mode.
113 cmdline = ['-a', 'arg1', '-b', '1', '--alpha', '--beta=2']
116 opts, args = getopt.gnu_getopt(cmdline, 'ab:', ['alpha', 'beta='])
118 self.assertEqual(opts, [('-a', ''), ('-b', '1'),
119 ('--alpha', ''), ('--beta', '2')])
121 # recognize "-" as an argument
122 opts, args = getopt.gnu_getopt(['-a', '-', '-b', '-'], 'ab:', [])
123 self.assertEqual(args, ['-'])
124 self.assertEqual(opts, [('-a', ''), ('-b', '-')])
127 opts, args = getopt.gnu_getopt(cmdline, '+ab:', ['alpha', 'beta='])
128 self.assertEqual(opts, [('-a', '')])
129 self.assertEqual(args, ['arg1', '-b', '1', '--alpha', '--beta=2'])
133 opts, args = getopt.gnu_getopt(cmdline, 'ab:', ['alpha', 'beta='])
134 self.assertEqual(opts, [('-a', '')])
135 self.assertEqual(args, ['arg1', '-b', '1', '--alpha', '--beta=2'])
145 >>> args = '-a -b -cfoo -d bar a1 a2'.split()
147 ['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']
150 [('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]
157 >>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'
160 ['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', 'a2']
162 ... 'condition=', 'output-file=', 'testing'])
164 [('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-x', '')]
174 longopts, shortopts = getopt.getopt(['--help='], '', ['help='])
175 self.assertEqual(longopts, [('--help', '')])
176 longopts, shortopts = getopt.getopt(['--help=x'], '', ['help='])
177 self.assertEqual(longopts, [('--help', 'x')])
178 self.assertRaises(getopt.GetoptError, getopt.getopt, ['--help='], '', ['help'])