2480
2481
self.assertConverted([u'bar'], opt, u'bar')
2484
class TestRegistryOption(tests.TestCase, TestOptionConverterMixin):
2486
def get_option(self, registry):
2487
return config.RegistryOption('foo', registry,
2488
help='A registry option.')
2490
def test_convert_invalid(self):
2491
registry = _mod_registry.Registry()
2492
opt = self.get_option(registry)
2493
self.assertConvertInvalid(opt, [1])
2494
self.assertConvertInvalid(opt, u"notregistered")
2496
def test_convert_valid(self):
2497
registry = _mod_registry.Registry()
2498
registry.register("someval", 1234)
2499
opt = self.get_option(registry)
2500
# Using a bare str() just in case
2501
self.assertConverted(1234, opt, "someval")
2502
self.assertConverted(1234, opt, u'someval')
2503
self.assertConverted(None, opt, None)
2505
def test_help(self):
2506
registry = _mod_registry.Registry()
2507
registry.register("someval", 1234, help="some option")
2508
registry.register("dunno", 1234, help="some other option")
2509
opt = self.get_option(registry)
2511
'A registry option.\n'
2513
'The following values are supported:\n'
2514
' dunno - some other option\n'
2515
' someval - some option\n',
2518
def test_get_help_text(self):
2519
registry = _mod_registry.Registry()
2520
registry.register("someval", 1234, help="some option")
2521
registry.register("dunno", 1234, help="some other option")
2522
opt = self.get_option(registry)
2524
'A registry option.\n'
2526
'The following values are supported:\n'
2527
' dunno - some other option\n'
2528
' someval - some option\n',
2529
opt.get_help_text())
2483
2532
class TestOptionRegistry(tests.TestCase):
2485
2534
def setUp(self):