MCPcopy Index your code
hub / github.com/python/cpython / assertParseOK

Method assertParseOK

Lib/test/test_optparse.py:50–78  ·  view source on GitHub ↗

Assert the options are what we expected when parsing arguments. Otherwise, fail with a nicely formatted message. Keyword arguments: args -- A list of arguments to parse with OptionParser. expected_opts -- The options expected. expected_positional_args -- The

(self, args, expected_opts, expected_positional_args)

Source from the content-addressed store, hash-verified

48
49class BaseTest(unittest.TestCase):
50 def assertParseOK(self, args, expected_opts, expected_positional_args):
51 """Assert the options are what we expected when parsing arguments.
52
53 Otherwise, fail with a nicely formatted message.
54
55 Keyword arguments:
56 args -- A list of arguments to parse with OptionParser.
57 expected_opts -- The options expected.
58 expected_positional_args -- The positional arguments expected.
59
60 Returns the options and positional args for further testing.
61 """
62
63 (options, positional_args) = self.parser.parse_args(args)
64 optdict = vars(options)
65
66 self.assertEqual(optdict, expected_opts,
67 """
68Options are %(optdict)s.
69Should be %(expected_opts)s.
70Args were %(args)s.""" % locals())
71
72 self.assertEqual(positional_args, expected_positional_args,
73 """
74Positional arguments are %(positional_args)s.
75Should be %(expected_positional_args)s.
76Args were %(args)s.""" % locals ())
77
78 return (options, positional_args)
79
80 def assertRaises(self,
81 func,

Calls 2

parse_argsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected