def test_valid_override(self): expected = (b'section', b'key', b'value') self.assertEqual(expected, config.parse_override(b'section/key=value')) self.assertEqual(expected, config.parse_override(b'section/key=value ')) self.assertEqual(expected, config.parse_override(b'section/key =value')) self.assertEqual(expected, config.parse_override(b'section /key=value'))
def test_empty_override(self): expected = ('section', 'key', '') self.assertEqual(expected, config.parse_override(b'section/key=')) self.assertEqual(expected, config.parse_override(b'section/key= '))
def test_valid_override_is_bytes(self): section, key, value = config.parse_override(b'section/key=value') self.assertIsInstance(section, bytes) self.assertIsInstance(key, bytes) self.assertIsInstance(value, bytes)
def check_config_override(option, opt, override): try: return config_lib.parse_override(override) except ValueError: raise optparse.OptionValueError( 'option %s: must have the format section/key=value' % opt)