MCPcopy Create free account
hub / github.com/EasyIME/PIME / test_subcommand

Method test_subcommand

python/python3/tornado/test/options_test.py:85–106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

83 self.assertIn("Usage:", usage)
84
85 def test_subcommand(self):
86 base_options = OptionParser()
87 base_options.define("verbose", default=False)
88 sub_options = OptionParser()
89 sub_options.define("foo", type=str)
90 rest = base_options.parse_command_line(
91 ["main.py", "--verbose", "subcommand", "--foo=bar"]
92 )
93 self.assertEqual(rest, ["subcommand", "--foo=bar"])
94 self.assertTrue(base_options.verbose)
95 rest2 = sub_options.parse_command_line(rest)
96 self.assertEqual(rest2, [])
97 self.assertEqual(sub_options.foo, "bar")
98
99 # the two option sets are distinct
100 try:
101 orig_stderr = sys.stderr
102 sys.stderr = StringIO()
103 with self.assertRaises(Error):
104 sub_options.parse_command_line(["subcommand", "--verbose"])
105 finally:
106 sys.stderr = orig_stderr
107
108 def test_setattr(self):
109 options = OptionParser()

Callers

nothing calls this directly

Calls 3

defineMethod · 0.95
parse_command_lineMethod · 0.95
OptionParserClass · 0.90

Tested by

no test coverage detected