MCPcopy
hub / github.com/tornadoweb/tornado / test_parse_callbacks

Method test_parse_callbacks

tornado/test/options_test.py:49–70  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

47 self.assertEqual(options.my_path, config_path)
48
49 def test_parse_callbacks(self):
50 options = OptionParser()
51 self.called = False
52
53 def callback():
54 self.called = True
55
56 options.add_parse_callback(callback)
57
58 # non-final parse doesn't run callbacks
59 options.parse_command_line(["main.py"], final=False)
60 self.assertFalse(self.called)
61
62 # final parse does
63 options.parse_command_line(["main.py"])
64 self.assertTrue(self.called)
65
66 # callbacks can be run more than once on the same options
67 # object if there are multiple final parses
68 self.called = False
69 options.parse_command_line(["main.py"])
70 self.assertTrue(self.called)
71
72 def test_help(self):
73 options = OptionParser()

Callers

nothing calls this directly

Calls 3

add_parse_callbackMethod · 0.95
parse_command_lineMethod · 0.95
OptionParserClass · 0.90

Tested by

no test coverage detected