def test_dash_underscore_file(self): # No matter how an option was defined, it can be set with underscores # in a config file. for defined_name in ['foo-bar', 'foo_bar']: options = OptionParser() options.define(defined_name) options.parse_config_file( os.path.join(os.path.dirname(__file__), "options_test.cfg")) self.assertEqual(options.foo_bar, 'a')
def test_parse_config_file(self): options = OptionParser() options.define("port", default=80) options.define("username", default='foo') options.define("my_path") config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "options_test.cfg") options.parse_config_file(config_path) self.assertEqual(options.port, 443) self.assertEqual(options.username, "李康") self.assertEqual(options.my_path, config_path)