def test_dash_underscore_introspection(self): # Original names are preserved in introspection APIs. options = OptionParser() options.define("with-dash", group="g") options.define("with_underscore", group="g") all_options = ["help", "with-dash", "with_underscore"] self.assertEqual(sorted(options), all_options) self.assertEqual(sorted(k for (k, v) in options.items()), all_options) self.assertEqual(sorted(options.as_dict().keys()), all_options) self.assertEqual(sorted(options.group_dict("g")), ["with-dash", "with_underscore"]) # --help shows CLI-style names with dashes. buf = StringIO() options.print_help(buf) self.assertIn("--with-dash", buf.getvalue()) self.assertIn("--with-underscore", buf.getvalue())
def test_dash_underscore_introspection(self): # Original names are preserved in introspection APIs. options = OptionParser() options.define('with-dash', group='g') options.define('with_underscore', group='g') all_options = ['help', 'with-dash', 'with_underscore'] self.assertEqual(sorted(options), all_options) self.assertEqual(sorted(k for (k, v) in options.items()), all_options) self.assertEqual(sorted(options.as_dict().keys()), all_options) self.assertEqual(sorted(options.group_dict('g')), ['with-dash', 'with_underscore']) # --help shows CLI-style names with dashes. buf = StringIO() options.print_help(buf) self.assertIn('--with-dash', buf.getvalue()) self.assertIn('--with-underscore', buf.getvalue())
def test_dash_underscore_introspection(self): # Original names are preserved in introspection APIs. options = OptionParser() options.define("with-dash", group="g") options.define("with_underscore", group="g") all_options = ["help", "with-dash", "with_underscore"] self.assertEqual(sorted(options), all_options) self.assertEqual(sorted(k for (k, v) in options.items()), all_options) self.assertEqual(sorted(options.as_dict().keys()), all_options) self.assertEqual( sorted(options.group_dict("g")), ["with-dash", "with_underscore"] ) # --help shows CLI-style names with dashes. buf = StringIO() options.print_help(buf) self.assertIn("--with-dash", buf.getvalue()) self.assertIn("--with-underscore", buf.getvalue())