496
501
def test_signatures_default(self):
497
502
my_config = config.Config()
499
self.applyDeprecated(deprecated_in((2, 5, 0)),
500
my_config.signature_needed))
503
self.assertFalse(my_config.signature_needed())
501
504
self.assertEqual(config.CHECK_IF_POSSIBLE,
502
self.applyDeprecated(deprecated_in((2, 5, 0)),
503
my_config.signature_checking))
505
my_config.signature_checking())
504
506
self.assertEqual(config.SIGN_WHEN_REQUIRED,
505
self.applyDeprecated(deprecated_in((2, 5, 0)),
506
my_config.signing_policy))
507
my_config.signing_policy())
508
509
def test_signatures_template_method(self):
509
510
my_config = InstrumentedConfig()
510
self.assertEqual(config.CHECK_NEVER,
511
self.applyDeprecated(deprecated_in((2, 5, 0)),
512
my_config.signature_checking))
511
self.assertEqual(config.CHECK_NEVER, my_config.signature_checking())
513
512
self.assertEqual(['_get_signature_checking'], my_config._calls)
515
514
def test_signatures_template_method_none(self):
516
515
my_config = InstrumentedConfig()
517
516
my_config._signatures = None
518
517
self.assertEqual(config.CHECK_IF_POSSIBLE,
519
self.applyDeprecated(deprecated_in((2, 5, 0)),
520
my_config.signature_checking))
518
my_config.signature_checking())
521
519
self.assertEqual(['_get_signature_checking'], my_config._calls)
523
521
def test_gpg_signing_command_default(self):
524
522
my_config = config.Config()
525
self.assertEqual('gpg',
526
self.applyDeprecated(deprecated_in((2, 5, 0)),
527
my_config.gpg_signing_command))
523
self.assertEqual('gpg', my_config.gpg_signing_command())
529
525
def test_get_user_option_default(self):
530
526
my_config = config.Config()
1255
1235
def test_signatures_always(self):
1256
1236
my_config = config.GlobalConfig.from_string(sample_always_signatures)
1257
1237
self.assertEqual(config.CHECK_NEVER,
1258
self.applyDeprecated(deprecated_in((2, 5, 0)),
1259
my_config.signature_checking))
1238
my_config.signature_checking())
1260
1239
self.assertEqual(config.SIGN_ALWAYS,
1261
self.applyDeprecated(deprecated_in((2, 5, 0)),
1262
my_config.signing_policy))
1263
self.assertEqual(True,
1264
self.applyDeprecated(deprecated_in((2, 5, 0)),
1265
my_config.signature_needed))
1240
my_config.signing_policy())
1241
self.assertEqual(True, my_config.signature_needed())
1267
1243
def test_signatures_if_possible(self):
1268
1244
my_config = config.GlobalConfig.from_string(sample_maybe_signatures)
1269
1245
self.assertEqual(config.CHECK_NEVER,
1270
self.applyDeprecated(deprecated_in((2, 5, 0)),
1271
my_config.signature_checking))
1246
my_config.signature_checking())
1272
1247
self.assertEqual(config.SIGN_WHEN_REQUIRED,
1273
self.applyDeprecated(deprecated_in((2, 5, 0)),
1274
my_config.signing_policy))
1275
self.assertEqual(False, self.applyDeprecated(deprecated_in((2, 5, 0)),
1276
my_config.signature_needed))
1248
my_config.signing_policy())
1249
self.assertEqual(False, my_config.signature_needed())
1278
1251
def test_signatures_ignore(self):
1279
1252
my_config = config.GlobalConfig.from_string(sample_ignore_signatures)
1280
1253
self.assertEqual(config.CHECK_ALWAYS,
1281
self.applyDeprecated(deprecated_in((2, 5, 0)),
1282
my_config.signature_checking))
1254
my_config.signature_checking())
1283
1255
self.assertEqual(config.SIGN_NEVER,
1284
self.applyDeprecated(deprecated_in((2, 5, 0)),
1285
my_config.signing_policy))
1286
self.assertEqual(False, self.applyDeprecated(deprecated_in((2, 5, 0)),
1287
my_config.signature_needed))
1256
my_config.signing_policy())
1257
self.assertEqual(False, my_config.signature_needed())
1289
1259
def _get_sample_config(self):
1290
1260
my_config = config.GlobalConfig.from_string(sample_config_text)
1581
1538
self.get_branch_config('http://www.example.com',
1582
1539
global_config=sample_ignore_signatures)
1583
1540
self.assertEqual(config.CHECK_ALWAYS,
1584
self.applyDeprecated(deprecated_in((2, 5, 0)),
1585
self.my_config.signature_checking))
1541
self.my_config.signature_checking())
1586
1542
self.assertEqual(config.SIGN_NEVER,
1587
self.applyDeprecated(deprecated_in((2, 5, 0)),
1588
self.my_config.signing_policy))
1543
self.my_config.signing_policy())
1590
1545
def test_signatures_never(self):
1591
1546
self.get_branch_config('/a/c')
1592
1547
self.assertEqual(config.CHECK_NEVER,
1593
self.applyDeprecated(deprecated_in((2, 5, 0)),
1594
self.my_config.signature_checking))
1548
self.my_config.signature_checking())
1596
1550
def test_signatures_when_available(self):
1597
1551
self.get_branch_config('/a/', global_config=sample_ignore_signatures)
1598
1552
self.assertEqual(config.CHECK_IF_POSSIBLE,
1599
self.applyDeprecated(deprecated_in((2, 5, 0)),
1600
self.my_config.signature_checking))
1553
self.my_config.signature_checking())
1602
1555
def test_signatures_always(self):
1603
1556
self.get_branch_config('/b')
1604
1557
self.assertEqual(config.CHECK_ALWAYS,
1605
self.applyDeprecated(deprecated_in((2, 5, 0)),
1606
self.my_config.signature_checking))
1558
self.my_config.signature_checking())
1608
1560
def test_gpg_signing_command(self):
1609
1561
self.get_branch_config('/b')
1610
self.assertEqual("gnome-gpg",
1611
self.applyDeprecated(deprecated_in((2, 5, 0)),
1612
self.my_config.gpg_signing_command))
1562
self.assertEqual("gnome-gpg", self.my_config.gpg_signing_command())
1614
1564
def test_gpg_signing_command_missing(self):
1615
1565
self.get_branch_config('/a')
1616
self.assertEqual("false",
1617
self.applyDeprecated(deprecated_in((2, 5, 0)),
1618
self.my_config.gpg_signing_command))
1566
self.assertEqual("false", self.my_config.gpg_signing_command())
1620
1568
def test_gpg_signing_key(self):
1621
1569
self.get_branch_config('/b')
1622
self.assertEqual("DD4D5088", self.applyDeprecated(deprecated_in((2, 5, 0)),
1623
self.my_config.gpg_signing_key))
1570
self.assertEqual("DD4D5088", self.my_config.gpg_signing_key())
1625
1572
def test_gpg_signing_key_default(self):
1626
1573
self.get_branch_config('/a')
1627
self.assertEqual("erik@bagfors.nu",
1628
self.applyDeprecated(deprecated_in((2, 5, 0)),
1629
self.my_config.gpg_signing_key))
1574
self.assertEqual("erik@bagfors.nu", self.my_config.gpg_signing_key())
1631
1576
def test_get_user_option_global(self):
1632
1577
self.get_branch_config('/a')
1836
1790
def test_signatures_forced(self):
1837
1791
my_config = self.get_branch_config(
1838
1792
global_config=sample_always_signatures)
1839
self.assertEqual(config.CHECK_NEVER,
1840
self.applyDeprecated(deprecated_in((2, 5, 0)),
1841
my_config.signature_checking))
1842
self.assertEqual(config.SIGN_ALWAYS,
1843
self.applyDeprecated(deprecated_in((2, 5, 0)),
1844
my_config.signing_policy))
1845
self.assertTrue(self.applyDeprecated(deprecated_in((2, 5, 0)),
1846
my_config.signature_needed))
1793
self.assertEqual(config.CHECK_NEVER, my_config.signature_checking())
1794
self.assertEqual(config.SIGN_ALWAYS, my_config.signing_policy())
1795
self.assertTrue(my_config.signature_needed())
1848
1797
def test_signatures_forced_branch(self):
1849
1798
my_config = self.get_branch_config(
1850
1799
global_config=sample_ignore_signatures,
1851
1800
branch_data_config=sample_always_signatures)
1852
self.assertEqual(config.CHECK_NEVER,
1853
self.applyDeprecated(deprecated_in((2, 5, 0)),
1854
my_config.signature_checking))
1855
self.assertEqual(config.SIGN_ALWAYS,
1856
self.applyDeprecated(deprecated_in((2, 5, 0)),
1857
my_config.signing_policy))
1858
self.assertTrue(self.applyDeprecated(deprecated_in((2, 5, 0)),
1859
my_config.signature_needed))
1801
self.assertEqual(config.CHECK_NEVER, my_config.signature_checking())
1802
self.assertEqual(config.SIGN_ALWAYS, my_config.signing_policy())
1803
self.assertTrue(my_config.signature_needed())
1861
1805
def test_gpg_signing_command(self):
1862
1806
my_config = self.get_branch_config(
1863
1807
global_config=sample_config_text,
1864
1808
# branch data cannot set gpg_signing_command
1865
1809
branch_data_config="gpg_signing_command=pgp")
1866
self.assertEqual('gnome-gpg',
1867
self.applyDeprecated(deprecated_in((2, 5, 0)),
1868
my_config.gpg_signing_command))
1810
self.assertEqual('gnome-gpg', my_config.gpg_signing_command())
1870
1812
def test_get_user_option_global(self):
1871
1813
my_config = self.get_branch_config(global_config=sample_config_text)
2322
2296
self.assertRaises(AssertionError, config.Option, 'foo',
2323
2297
default=object())
2325
def test_not_supported_callable_default_value_not_unicode(self):
2326
def bar_not_unicode():
2328
opt = config.Option('foo', default=bar_not_unicode)
2329
self.assertRaises(AssertionError, opt.get_default)
2332
class TestOptionConverterMixin(object):
2334
def assertConverted(self, expected, opt, value):
2335
self.assertEquals(expected, opt.convert_from_unicode(None, value))
2337
def assertWarns(self, opt, value):
2340
warnings.append(args[0] % args[1:])
2341
self.overrideAttr(trace, 'warning', warning)
2342
self.assertEquals(None, opt.convert_from_unicode(None, value))
2343
self.assertLength(1, warnings)
2345
'Value "%s" is not valid for "%s"' % (value, opt.name),
2348
def assertErrors(self, opt, value):
2349
self.assertRaises(errors.ConfigOptionValueError,
2350
opt.convert_from_unicode, None, value)
2352
def assertConvertInvalid(self, opt, invalid_value):
2354
self.assertEquals(None, opt.convert_from_unicode(None, invalid_value))
2355
opt.invalid = 'warning'
2356
self.assertWarns(opt, invalid_value)
2357
opt.invalid = 'error'
2358
self.assertErrors(opt, invalid_value)
2361
class TestOptionWithBooleanConverter(tests.TestCase, TestOptionConverterMixin):
2363
def get_option(self):
2364
return config.Option('foo', help='A boolean.',
2365
from_unicode=config.bool_from_store)
2367
def test_convert_invalid(self):
2368
opt = self.get_option()
2369
# A string that is not recognized as a boolean
2370
self.assertConvertInvalid(opt, u'invalid-boolean')
2371
# A list of strings is never recognized as a boolean
2372
self.assertConvertInvalid(opt, [u'not', u'a', u'boolean'])
2374
def test_convert_valid(self):
2375
opt = self.get_option()
2376
self.assertConverted(True, opt, u'True')
2377
self.assertConverted(True, opt, u'1')
2378
self.assertConverted(False, opt, u'False')
2381
class TestOptionWithIntegerConverter(tests.TestCase, TestOptionConverterMixin):
2383
def get_option(self):
2384
return config.Option('foo', help='An integer.',
2385
from_unicode=config.int_from_store)
2387
def test_convert_invalid(self):
2388
opt = self.get_option()
2389
# A string that is not recognized as an integer
2390
self.assertConvertInvalid(opt, u'forty-two')
2391
# A list of strings is never recognized as an integer
2392
self.assertConvertInvalid(opt, [u'a', u'list'])
2394
def test_convert_valid(self):
2395
opt = self.get_option()
2396
self.assertConverted(16, opt, u'16')
2399
class TestOptionWithSIUnitConverter(tests.TestCase, TestOptionConverterMixin):
2401
def get_option(self):
2402
return config.Option('foo', help='An integer in SI units.',
2403
from_unicode=config.int_SI_from_store)
2405
def test_convert_invalid(self):
2406
opt = self.get_option()
2407
self.assertConvertInvalid(opt, u'not-a-unit')
2408
self.assertConvertInvalid(opt, u'Gb') # Forgot the int
2409
self.assertConvertInvalid(opt, u'1b') # Forgot the unit
2410
self.assertConvertInvalid(opt, u'1GG')
2411
self.assertConvertInvalid(opt, u'1Mbb')
2412
self.assertConvertInvalid(opt, u'1MM')
2414
def test_convert_valid(self):
2415
opt = self.get_option()
2416
self.assertConverted(int(5e3), opt, u'5kb')
2417
self.assertConverted(int(5e6), opt, u'5M')
2418
self.assertConverted(int(5e6), opt, u'5MB')
2419
self.assertConverted(int(5e9), opt, u'5g')
2420
self.assertConverted(int(5e9), opt, u'5gB')
2421
self.assertConverted(100, opt, u'100')
2424
class TestListOption(tests.TestCase, TestOptionConverterMixin):
2426
def get_option(self):
2427
return config.ListOption('foo', help='A list.')
2300
class TestOptionConverterMixin(object):
2302
def assertConverted(self, expected, opt, value):
2303
self.assertEquals(expected, opt.convert_from_unicode(value))
2305
def assertWarns(self, opt, value):
2308
warnings.append(args[0] % args[1:])
2309
self.overrideAttr(trace, 'warning', warning)
2310
self.assertEquals(None, opt.convert_from_unicode(value))
2311
self.assertLength(1, warnings)
2313
'Value "%s" is not valid for "%s"' % (value, opt.name),
2316
def assertErrors(self, opt, value):
2317
self.assertRaises(errors.ConfigOptionValueError,
2318
opt.convert_from_unicode, value)
2320
def assertConvertInvalid(self, opt, invalid_value):
2322
self.assertEquals(None, opt.convert_from_unicode(invalid_value))
2323
opt.invalid = 'warning'
2324
self.assertWarns(opt, invalid_value)
2325
opt.invalid = 'error'
2326
self.assertErrors(opt, invalid_value)
2329
class TestOptionWithBooleanConverter(tests.TestCase, TestOptionConverterMixin):
2331
def get_option(self):
2332
return config.Option('foo', help='A boolean.',
2333
from_unicode=config.bool_from_store)
2335
def test_convert_invalid(self):
2336
opt = self.get_option()
2337
# A string that is not recognized as a boolean
2338
self.assertConvertInvalid(opt, u'invalid-boolean')
2339
# A list of strings is never recognized as a boolean
2340
self.assertConvertInvalid(opt, [u'not', u'a', u'boolean'])
2342
def test_convert_valid(self):
2343
opt = self.get_option()
2344
self.assertConverted(True, opt, u'True')
2345
self.assertConverted(True, opt, u'1')
2346
self.assertConverted(False, opt, u'False')
2349
class TestOptionWithIntegerConverter(tests.TestCase, TestOptionConverterMixin):
2351
def get_option(self):
2352
return config.Option('foo', help='An integer.',
2353
from_unicode=config.int_from_store)
2355
def test_convert_invalid(self):
2356
opt = self.get_option()
2357
# A string that is not recognized as an integer
2358
self.assertConvertInvalid(opt, u'forty-two')
2359
# A list of strings is never recognized as an integer
2360
self.assertConvertInvalid(opt, [u'a', u'list'])
2362
def test_convert_valid(self):
2363
opt = self.get_option()
2364
self.assertConverted(16, opt, u'16')
2366
class TestOptionWithListConverter(tests.TestCase, TestOptionConverterMixin):
2368
def get_option(self):
2369
return config.Option('foo', help='A list.',
2370
from_unicode=config.list_from_store)
2372
def test_convert_invalid(self):
2373
# No string is invalid as all forms can be converted to a list
2376
def test_convert_valid(self):
2377
opt = self.get_option()
2378
# An empty string is an empty list
2379
self.assertConverted([], opt, '') # Using a bare str() just in case
2380
self.assertConverted([], opt, u'')
2382
self.assertConverted([u'True'], opt, u'True')
2384
self.assertConverted([u'42'], opt, u'42')
2386
self.assertConverted([u'bar'], opt, u'bar')
2387
# A list remains a list (configObj will turn a string containing commas
2388
# into a list, but that's not what we're testing here)
2389
self.assertConverted([u'foo', u'1', u'True'],
2390
opt, [u'foo', u'1', u'True'])
2393
class TestOptionConverterMixin(object):
2395
def assertConverted(self, expected, opt, value):
2396
self.assertEquals(expected, opt.convert_from_unicode(value))
2398
def assertWarns(self, opt, value):
2401
warnings.append(args[0] % args[1:])
2402
self.overrideAttr(trace, 'warning', warning)
2403
self.assertEquals(None, opt.convert_from_unicode(value))
2404
self.assertLength(1, warnings)
2406
'Value "%s" is not valid for "%s"' % (value, opt.name),
2409
def assertErrors(self, opt, value):
2410
self.assertRaises(errors.ConfigOptionValueError,
2411
opt.convert_from_unicode, value)
2413
def assertConvertInvalid(self, opt, invalid_value):
2415
self.assertEquals(None, opt.convert_from_unicode(invalid_value))
2416
opt.invalid = 'warning'
2417
self.assertWarns(opt, invalid_value)
2418
opt.invalid = 'error'
2419
self.assertErrors(opt, invalid_value)
2422
class TestOptionWithBooleanConverter(tests.TestCase, TestOptionConverterMixin):
2424
def get_option(self):
2425
return config.Option('foo', help='A boolean.',
2426
from_unicode=config.bool_from_store)
2428
def test_convert_invalid(self):
2429
opt = self.get_option()
2430
# A string that is not recognized as a boolean
2431
self.assertConvertInvalid(opt, u'invalid-boolean')
2432
# A list of strings is never recognized as a boolean
2433
self.assertConvertInvalid(opt, [u'not', u'a', u'boolean'])
2435
def test_convert_valid(self):
2436
opt = self.get_option()
2437
self.assertConverted(True, opt, u'True')
2438
self.assertConverted(True, opt, u'1')
2439
self.assertConverted(False, opt, u'False')
2442
class TestOptionWithIntegerConverter(tests.TestCase, TestOptionConverterMixin):
2444
def get_option(self):
2445
return config.Option('foo', help='An integer.',
2446
from_unicode=config.int_from_store)
2448
def test_convert_invalid(self):
2449
opt = self.get_option()
2450
# A string that is not recognized as an integer
2451
self.assertConvertInvalid(opt, u'forty-two')
2452
# A list of strings is never recognized as an integer
2453
self.assertConvertInvalid(opt, [u'a', u'list'])
2455
def test_convert_valid(self):
2456
opt = self.get_option()
2457
self.assertConverted(16, opt, u'16')
2460
class TestOptionWithListConverter(tests.TestCase, TestOptionConverterMixin):
2462
def get_option(self):
2463
return config.Option('foo', help='A list.',
2464
from_unicode=config.list_from_store)
2429
2466
def test_convert_invalid(self):
2430
2467
opt = self.get_option()
2446
2483
self.assertConverted([u'bar'], opt, u'bar')
2449
class TestRegistryOption(tests.TestCase, TestOptionConverterMixin):
2451
def get_option(self, registry):
2452
return config.RegistryOption('foo', registry,
2453
help='A registry option.')
2455
def test_convert_invalid(self):
2456
registry = _mod_registry.Registry()
2457
opt = self.get_option(registry)
2458
self.assertConvertInvalid(opt, [1])
2459
self.assertConvertInvalid(opt, u"notregistered")
2461
def test_convert_valid(self):
2462
registry = _mod_registry.Registry()
2463
registry.register("someval", 1234)
2464
opt = self.get_option(registry)
2465
# Using a bare str() just in case
2466
self.assertConverted(1234, opt, "someval")
2467
self.assertConverted(1234, opt, u'someval')
2468
self.assertConverted(None, opt, None)
2470
def test_help(self):
2471
registry = _mod_registry.Registry()
2472
registry.register("someval", 1234, help="some option")
2473
registry.register("dunno", 1234, help="some other option")
2474
opt = self.get_option(registry)
2476
'A registry option.\n'
2478
'The following values are supported:\n'
2479
' dunno - some other option\n'
2480
' someval - some option\n',
2483
def test_get_help_text(self):
2484
registry = _mod_registry.Registry()
2485
registry.register("someval", 1234, help="some option")
2486
registry.register("dunno", 1234, help="some other option")
2487
opt = self.get_option(registry)
2489
'A registry option.\n'
2491
'The following values are supported:\n'
2492
' dunno - some other option\n'
2493
' someval - some option\n',
2494
opt.get_help_text())
2497
2486
class TestOptionRegistry(tests.TestCase):
2499
2488
def setUp(self):
2623
2615
self.assertEquals(config._NewlyCreatedOption, section.orig['foo'])
2626
class TestCommandLineStore(tests.TestCase):
2618
class TestCommandLineSection(tests.TestCase):
2628
2620
def setUp(self):
2629
super(TestCommandLineStore, self).setUp()
2630
self.store = config.CommandLineStore()
2631
self.overrideAttr(config, 'option_registry', config.OptionRegistry())
2633
def get_section(self):
2634
"""Get the unique section for the command line overrides."""
2635
sections = list(self.store.get_sections())
2636
self.assertLength(1, sections)
2637
store, section = sections[0]
2638
self.assertEquals(self.store, store)
2621
super(TestCommandLineSection, self).setUp()
2622
self.section = config.CommandLineSection()
2641
2624
def test_no_override(self):
2642
self.store._from_cmdline([])
2643
section = self.get_section()
2644
self.assertLength(0, list(section.iter_option_names()))
2625
self.section._from_cmdline([])
2626
# FIXME: we want some iterator over all options, failing that, we peek
2627
# under the cover -- vila 2011-09026
2628
self.assertLength(0, self.section.options)
2646
2630
def test_simple_override(self):
2647
self.store._from_cmdline(['a=b'])
2648
section = self.get_section()
2649
self.assertEqual('b', section.get('a'))
2631
self.section._from_cmdline(['a=b'])
2632
self.assertEqual('b', self.section.get('a'))
2651
2634
def test_list_override(self):
2652
opt = config.ListOption('l')
2653
config.option_registry.register(opt)
2654
self.store._from_cmdline(['l=1,2,3'])
2655
val = self.get_section().get('l')
2635
self.section._from_cmdline(['l=1,2,3'])
2636
val = self.section.get('l')
2656
2637
self.assertEqual('1,2,3', val)
2657
# Reminder: lists should be registered as such explicitely, otherwise
2658
# the conversion needs to be done afterwards.
2659
self.assertEqual(['1', '2', '3'],
2660
opt.convert_from_unicode(self.store, val))
2638
# Reminder: lists should registered as such explicitely, otherwise the
2639
# conversion needs to be done afterwards.
2640
self.assertEqual(['1', '2', '3'], config.list_from_store(val))
2662
2642
def test_multiple_overrides(self):
2663
self.store._from_cmdline(['a=b', 'x=y'])
2664
section = self.get_section()
2665
self.assertEquals('b', section.get('a'))
2666
self.assertEquals('y', section.get('x'))
2643
self.section._from_cmdline(['a=b', 'x=y'])
2644
self.assertEquals('b', self.section.get('a'))
2645
self.assertEquals('y', self.section.get('x'))
2668
2647
def test_wrong_syntax(self):
2669
2648
self.assertRaises(errors.BzrCommandError,
2670
self.store._from_cmdline, ['a=b', 'c'])
2672
class TestStoreMinimalAPI(tests.TestCaseWithTransport):
2674
scenarios = [(key, {'get_store': builder}) for key, builder
2675
in config.test_store_builder_registry.iteritems()] + [
2676
('cmdline', {'get_store': lambda test: config.CommandLineStore()})]
2679
store = self.get_store(self)
2680
if type(store) == config.TransportIniFileStore:
2681
raise tests.TestNotApplicable(
2682
"%s is not a concrete Store implementation"
2683
" so it doesn't need an id" % (store.__class__.__name__,))
2684
self.assertIsNot(None, store.id)
2649
self.section._from_cmdline, ['a=b', 'c'])
2687
2652
class TestStore(tests.TestCaseWithTransport):
2689
def assertSectionContent(self, expected, (store, section)):
2654
def assertSectionContent(self, expected, section):
2690
2655
"""Assert that some options have the proper values in a section."""
2691
2656
expected_name, expected_options = expected
2692
2657
self.assertEquals(expected_name, section.id)
2731
2696
self.assertRaises(AssertionError, store._load_from_string, 'bar=baz')
2734
class TestStoreQuoting(TestStore):
2736
scenarios = [(key, {'get_store': builder}) for key, builder
2737
in config.test_store_builder_registry.iteritems()]
2740
super(TestStoreQuoting, self).setUp()
2741
self.store = self.get_store(self)
2742
# We need a loaded store but any content will do
2743
self.store._load_from_string('')
2745
def assertIdempotent(self, s):
2746
"""Assert that quoting an unquoted string is a no-op and vice-versa.
2748
What matters here is that option values, as they appear in a store, can
2749
be safely round-tripped out of the store and back.
2751
:param s: A string, quoted if required.
2753
self.assertEquals(s, self.store.quote(self.store.unquote(s)))
2754
self.assertEquals(s, self.store.unquote(self.store.quote(s)))
2756
def test_empty_string(self):
2757
if isinstance(self.store, config.IniFileStore):
2758
# configobj._quote doesn't handle empty values
2759
self.assertRaises(AssertionError,
2760
self.assertIdempotent, '')
2762
self.assertIdempotent('')
2763
# But quoted empty strings are ok
2764
self.assertIdempotent('""')
2766
def test_embedded_spaces(self):
2767
self.assertIdempotent('" a b c "')
2769
def test_embedded_commas(self):
2770
self.assertIdempotent('" a , b c "')
2772
def test_simple_comma(self):
2773
if isinstance(self.store, config.IniFileStore):
2774
# configobj requires that lists are special-cased
2775
self.assertRaises(AssertionError,
2776
self.assertIdempotent, ',')
2778
self.assertIdempotent(',')
2779
# When a single comma is required, quoting is also required
2780
self.assertIdempotent('","')
2782
def test_list(self):
2783
if isinstance(self.store, config.IniFileStore):
2784
# configobj requires that lists are special-cased
2785
self.assertRaises(AssertionError,
2786
self.assertIdempotent, 'a,b')
2788
self.assertIdempotent('a,b')
2791
class TestDictFromStore(tests.TestCase):
2793
def test_unquote_not_string(self):
2794
conf = config.MemoryStack('x=2\n[a_section]\na=1\n')
2795
value = conf.get('a_section')
2796
# Urgh, despite 'conf' asking for the no-name section, we get the
2797
# content of another section as a dict o_O
2798
self.assertEquals({'a': '1'}, value)
2799
unquoted = conf.store.unquote(value)
2800
# Which cannot be unquoted but shouldn't crash either (the use cases
2801
# are getting the value or displaying it. In the later case, '%s' will
2803
self.assertEquals({'a': '1'}, unquoted)
2804
self.assertEquals("{u'a': u'1'}", '%s' % (unquoted,))
2807
2699
class TestIniFileStoreContent(tests.TestCaseWithTransport):
2808
2700
"""Simulate loading a config store with content of various encodings.
3033
2900
config.ConfigHooks.install_named_hook('save', hook, None)
3034
2901
self.assertLength(0, calls)
3035
2902
store = self.get_store(self)
3036
# FIXME: There should be a better way than relying on the test
3037
# parametrization to identify branch.conf -- vila 2011-0526
3038
if self.store_id in ('branch', 'remote_branch'):
3039
# branch stores requires write locked branches
3040
self.addCleanup(store.branch.lock_write().unlock)
3041
2903
section = store.get_mutable_section('baz')
3042
2904
section.set('foo', 'bar')
3044
2906
self.assertLength(1, calls)
3045
2907
self.assertEquals((store,), calls[0])
3047
def test_set_mark_dirty(self):
3048
stack = config.MemoryStack('')
3049
self.assertLength(0, stack.store.dirty_sections)
3050
stack.set('foo', 'baz')
3051
self.assertLength(1, stack.store.dirty_sections)
3052
self.assertTrue(stack.store._need_saving())
3054
def test_remove_mark_dirty(self):
3055
stack = config.MemoryStack('foo=bar')
3056
self.assertLength(0, stack.store.dirty_sections)
3058
self.assertLength(1, stack.store.dirty_sections)
3059
self.assertTrue(stack.store._need_saving())
3062
class TestStoreSaveChanges(tests.TestCaseWithTransport):
3063
"""Tests that config changes are kept in memory and saved on-demand."""
3066
super(TestStoreSaveChanges, self).setUp()
3067
self.transport = self.get_transport()
3068
# Most of the tests involve two stores pointing to the same persistent
3069
# storage to observe the effects of concurrent changes
3070
self.st1 = config.TransportIniFileStore(self.transport, 'foo.conf')
3071
self.st2 = config.TransportIniFileStore(self.transport, 'foo.conf')
3074
self.warnings.append(args[0] % args[1:])
3075
self.overrideAttr(trace, 'warning', warning)
3077
def has_store(self, store):
3078
store_basename = urlutils.relative_url(self.transport.external_url(),
3079
store.external_url())
3080
return self.transport.has(store_basename)
3082
def get_stack(self, store):
3083
# Any stack will do as long as it uses the right store, just a single
3084
# no-name section is enough
3085
return config.Stack([store.get_sections], store)
3087
def test_no_changes_no_save(self):
3088
s = self.get_stack(self.st1)
3089
s.store.save_changes()
3090
self.assertEquals(False, self.has_store(self.st1))
3092
def test_unrelated_concurrent_update(self):
3093
s1 = self.get_stack(self.st1)
3094
s2 = self.get_stack(self.st2)
3095
s1.set('foo', 'bar')
3096
s2.set('baz', 'quux')
3098
# Changes don't propagate magically
3099
self.assertEquals(None, s1.get('baz'))
3100
s2.store.save_changes()
3101
self.assertEquals('quux', s2.get('baz'))
3102
# Changes are acquired when saving
3103
self.assertEquals('bar', s2.get('foo'))
3104
# Since there is no overlap, no warnings are emitted
3105
self.assertLength(0, self.warnings)
3107
def test_concurrent_update_modified(self):
3108
s1 = self.get_stack(self.st1)
3109
s2 = self.get_stack(self.st2)
3110
s1.set('foo', 'bar')
3111
s2.set('foo', 'baz')
3114
s2.store.save_changes()
3115
self.assertEquals('baz', s2.get('foo'))
3116
# But the user get a warning
3117
self.assertLength(1, self.warnings)
3118
warning = self.warnings[0]
3119
self.assertStartsWith(warning, 'Option foo in section None')
3120
self.assertEndsWith(warning, 'was changed from <CREATED> to bar.'
3121
' The baz value will be saved.')
3123
def test_concurrent_deletion(self):
3124
self.st1._load_from_string('foo=bar')
3126
s1 = self.get_stack(self.st1)
3127
s2 = self.get_stack(self.st2)
3130
s1.store.save_changes()
3132
self.assertLength(0, self.warnings)
3133
s2.store.save_changes()
3135
self.assertLength(1, self.warnings)
3136
warning = self.warnings[0]
3137
self.assertStartsWith(warning, 'Option foo in section None')
3138
self.assertEndsWith(warning, 'was changed from bar to <CREATED>.'
3139
' The <DELETED> value will be saved.')
3142
class TestQuotingIniFileStore(tests.TestCaseWithTransport):
3144
def get_store(self):
3145
return config.TransportIniFileStore(self.get_transport(), 'foo.conf')
3147
def test_get_quoted_string(self):
3148
store = self.get_store()
3149
store._load_from_string('foo= " abc "')
3150
stack = config.Stack([store.get_sections])
3151
self.assertEquals(' abc ', stack.get('foo'))
3153
def test_set_quoted_string(self):
3154
store = self.get_store()
3155
stack = config.Stack([store.get_sections], store)
3156
stack.set('foo', ' a b c ')
3158
self.assertFileEqual('foo = " a b c "' + os.linesep, 'foo.conf')
3161
class TestTransportIniFileStore(TestStore):
2910
class TestIniFileStore(TestStore):
3163
2912
def test_loading_unknown_file_fails(self):
3164
store = config.TransportIniFileStore(self.get_transport(),
2913
store = config.IniFileStore(self.get_transport(), 'I-do-not-exist')
3166
2914
self.assertRaises(errors.NoSuchFile, store.load)
3168
2916
def test_invalid_content(self):
3169
store = config.TransportIniFileStore(self.get_transport(), 'foo.conf')
2917
store = config.IniFileStore(self.get_transport(), 'foo.conf', )
3170
2918
self.assertEquals(False, store.is_loaded())
3171
2919
exc = self.assertRaises(
3172
2920
errors.ParseConfigError, store._load_from_string,
3471
3224
self.assertEquals(expected_location, matcher.location)
3474
class TestStartingPathMatcher(TestStore):
3477
super(TestStartingPathMatcher, self).setUp()
3478
# Any simple store is good enough
3479
self.store = config.IniFileStore()
3481
def assertSectionIDs(self, expected, location, content):
3482
self.store._load_from_string(content)
3483
matcher = config.StartingPathMatcher(self.store, location)
3484
sections = list(matcher.get_sections())
3485
self.assertLength(len(expected), sections)
3486
self.assertEqual(expected, [section.id for _, section in sections])
3489
def test_empty(self):
3490
self.assertSectionIDs([], self.get_url(), '')
3492
def test_url_vs_local_paths(self):
3493
# The matcher location is an url and the section names are local paths
3494
sections = self.assertSectionIDs(['/foo/bar', '/foo'],
3495
'file:///foo/bar/baz', '''\
3500
def test_local_path_vs_url(self):
3501
# The matcher location is a local path and the section names are urls
3502
sections = self.assertSectionIDs(['file:///foo/bar', 'file:///foo'],
3503
'/foo/bar/baz', '''\
3509
def test_no_name_section_included_when_present(self):
3510
# Note that other tests will cover the case where the no-name section
3511
# is empty and as such, not included.
3512
sections = self.assertSectionIDs(['/foo/bar', '/foo', None],
3513
'/foo/bar/baz', '''\
3514
option = defined so the no-name section exists
3518
self.assertEquals(['baz', 'bar/baz', '/foo/bar/baz'],
3519
[s.locals['relpath'] for _, s in sections])
3521
def test_order_reversed(self):
3522
self.assertSectionIDs(['/foo/bar', '/foo'], '/foo/bar/baz', '''\
3527
def test_unrelated_section_excluded(self):
3528
self.assertSectionIDs(['/foo/bar', '/foo'], '/foo/bar/baz', '''\
3534
def test_glob_included(self):
3535
sections = self.assertSectionIDs(['/foo/*/baz', '/foo/b*', '/foo'],
3536
'/foo/bar/baz', '''\
3542
# Note that 'baz' as a relpath for /foo/b* is not fully correct, but
3543
# nothing really is... as far using {relpath} to append it to something
3544
# else, this seems good enough though.
3545
self.assertEquals(['', 'baz', 'bar/baz'],
3546
[s.locals['relpath'] for _, s in sections])
3548
def test_respect_order(self):
3549
self.assertSectionIDs(['/foo', '/foo/b*', '/foo/*/baz'],
3550
'/foo/bar/baz', '''\
3558
3227
class TestNameMatcher(TestStore):
3560
3229
def setUp(self):
3586
3255
self.assertLength(0, sections)
3589
class TestBaseStackGet(tests.TestCase):
3592
super(TestBaseStackGet, self).setUp()
3258
class TestStackGet(tests.TestCase):
3260
# FIXME: This should be parametrized for all known Stack or dedicated
3261
# paramerized tests created to avoid bloating -- vila 2011-03-31
3263
def overrideOptionRegistry(self):
3593
3264
self.overrideAttr(config, 'option_registry', config.OptionRegistry())
3595
def test_get_first_definition(self):
3596
store1 = config.IniFileStore()
3597
store1._load_from_string('foo=bar')
3598
store2 = config.IniFileStore()
3599
store2._load_from_string('foo=baz')
3600
conf = config.Stack([store1.get_sections, store2.get_sections])
3601
self.assertEquals('bar', conf.get('foo'))
3266
def test_single_config_get(self):
3267
conf = dict(foo='bar')
3268
conf_stack = config.Stack([conf])
3269
self.assertEquals('bar', conf_stack.get('foo'))
3603
3271
def test_get_with_registered_default_value(self):
3604
config.option_registry.register(config.Option('foo', default='bar'))
3605
conf_stack = config.Stack([])
3272
conf_stack = config.Stack([dict()])
3273
opt = config.Option('foo', default='bar')
3274
self.overrideOptionRegistry()
3275
config.option_registry.register('foo', opt)
3606
3276
self.assertEquals('bar', conf_stack.get('foo'))
3608
3278
def test_get_without_registered_default_value(self):
3609
config.option_registry.register(config.Option('foo'))
3610
conf_stack = config.Stack([])
3279
conf_stack = config.Stack([dict()])
3280
opt = config.Option('foo')
3281
self.overrideOptionRegistry()
3282
config.option_registry.register('foo', opt)
3611
3283
self.assertEquals(None, conf_stack.get('foo'))
3613
3285
def test_get_without_default_value_for_not_registered(self):
3614
conf_stack = config.Stack([])
3286
conf_stack = config.Stack([dict()])
3287
opt = config.Option('foo')
3288
self.overrideOptionRegistry()
3615
3289
self.assertEquals(None, conf_stack.get('foo'))
3291
def test_get_first_definition(self):
3292
conf1 = dict(foo='bar')
3293
conf2 = dict(foo='baz')
3294
conf_stack = config.Stack([conf1, conf2])
3295
self.assertEquals('bar', conf_stack.get('foo'))
3297
def test_get_embedded_definition(self):
3298
conf1 = dict(yy='12')
3299
conf2 = config.Stack([dict(xx='42'), dict(foo='baz')])
3300
conf_stack = config.Stack([conf1, conf2])
3301
self.assertEquals('baz', conf_stack.get('foo'))
3617
3303
def test_get_for_empty_section_callable(self):
3618
3304
conf_stack = config.Stack([lambda : []])
3619
3305
self.assertEquals(None, conf_stack.get('foo'))
3621
3307
def test_get_for_broken_callable(self):
3622
3308
# Trying to use and invalid callable raises an exception on first use
3623
conf_stack = config.Stack([object])
3309
conf_stack = config.Stack([lambda : object()])
3624
3310
self.assertRaises(TypeError, conf_stack.get, 'foo')
3627
class TestStackWithSimpleStore(tests.TestCase):
3630
super(TestStackWithSimpleStore, self).setUp()
3631
self.overrideAttr(config, 'option_registry', config.OptionRegistry())
3632
self.registry = config.option_registry
3634
def get_conf(self, content=None):
3635
return config.MemoryStack(content)
3637
def test_override_value_from_env(self):
3638
self.registry.register(
3639
config.Option('foo', default='bar', override_from_env=['FOO']))
3640
self.overrideEnv('FOO', 'quux')
3641
# Env variable provides a default taking over the option one
3642
conf = self.get_conf('foo=store')
3643
self.assertEquals('quux', conf.get('foo'))
3645
def test_first_override_value_from_env_wins(self):
3646
self.registry.register(
3647
config.Option('foo', default='bar',
3648
override_from_env=['NO_VALUE', 'FOO', 'BAZ']))
3649
self.overrideEnv('FOO', 'foo')
3650
self.overrideEnv('BAZ', 'baz')
3651
# The first env var set wins
3652
conf = self.get_conf('foo=store')
3653
self.assertEquals('foo', conf.get('foo'))
3656
class TestMemoryStack(tests.TestCase):
3659
conf = config.MemoryStack('foo=bar')
3660
self.assertEquals('bar', conf.get('foo'))
3663
conf = config.MemoryStack('foo=bar')
3664
conf.set('foo', 'baz')
3665
self.assertEquals('baz', conf.get('foo'))
3667
def test_no_content(self):
3668
conf = config.MemoryStack()
3669
# No content means no loading
3670
self.assertFalse(conf.store.is_loaded())
3671
self.assertRaises(NotImplementedError, conf.get, 'foo')
3672
# But a content can still be provided
3673
conf.store._load_from_string('foo=bar')
3674
self.assertEquals('bar', conf.get('foo'))
3677
class TestStackIterSections(tests.TestCase):
3679
def test_empty_stack(self):
3680
conf = config.Stack([])
3681
sections = list(conf.iter_sections())
3682
self.assertLength(0, sections)
3684
def test_empty_store(self):
3685
store = config.IniFileStore()
3686
store._load_from_string('')
3687
conf = config.Stack([store.get_sections])
3688
sections = list(conf.iter_sections())
3689
self.assertLength(0, sections)
3691
def test_simple_store(self):
3692
store = config.IniFileStore()
3693
store._load_from_string('foo=bar')
3694
conf = config.Stack([store.get_sections])
3695
tuples = list(conf.iter_sections())
3696
self.assertLength(1, tuples)
3697
(found_store, found_section) = tuples[0]
3698
self.assertIs(store, found_store)
3700
def test_two_stores(self):
3701
store1 = config.IniFileStore()
3702
store1._load_from_string('foo=bar')
3703
store2 = config.IniFileStore()
3704
store2._load_from_string('bar=qux')
3705
conf = config.Stack([store1.get_sections, store2.get_sections])
3706
tuples = list(conf.iter_sections())
3707
self.assertLength(2, tuples)
3708
self.assertIs(store1, tuples[0][0])
3709
self.assertIs(store2, tuples[1][0])
3712
3313
class TestStackWithTransport(tests.TestCaseWithTransport):
3714
3315
scenarios = [(key, {'get_stack': builder}) for key, builder
3801
3394
def test_get_default_integer_None(self):
3802
3395
self.register_integer_option('foo')
3803
conf = self.get_conf('')
3804
self.assertEquals(None, conf.get('foo'))
3396
self.assertEquals(None, self.conf.get('foo'))
3806
3398
def test_get_default_integer(self):
3807
3399
self.register_integer_option('foo', 42)
3808
conf = self.get_conf('')
3809
self.assertEquals(42, conf.get('foo'))
3400
self.assertEquals(42, self.conf.get('foo'))
3811
3402
def test_get_default_integer_as_string(self):
3812
3403
self.register_integer_option('foo', u'42')
3813
conf = self.get_conf('')
3814
self.assertEquals(42, conf.get('foo'))
3404
self.assertEquals(42, self.conf.get('foo'))
3816
3406
def test_get_default_integer_from_env(self):
3817
3407
self.register_integer_option('foo', default_from_env=['FOO'])
3818
3408
self.overrideEnv('FOO', '18')
3819
conf = self.get_conf('')
3820
self.assertEquals(18, conf.get('foo'))
3409
self.assertEquals(18, self.conf.get('foo'))
3822
3411
def test_get_default_integer_when_conversion_fails(self):
3823
3412
self.register_integer_option('foo', default='12')
3824
conf = self.get_conf('foo=invalid integer')
3825
self.assertEquals(12, conf.get('foo'))
3413
self.conf.store._load_from_string('foo=invalid integer')
3414
self.assertEquals(12, self.conf.get('foo'))
3827
3416
def register_list_option(self, name, default=None, default_from_env=None):
3828
l = config.ListOption(name, help='A list.', default=default,
3829
default_from_env=default_from_env)
3417
l = config.Option(name, help='A list.',
3418
default=default, default_from_env=default_from_env,
3419
from_unicode=config.list_from_store)
3830
3420
self.registry.register(l)
3832
3422
def test_get_default_list_None(self):
3833
3423
self.register_list_option('foo')
3834
conf = self.get_conf('')
3835
self.assertEquals(None, conf.get('foo'))
3424
self.assertEquals(None, self.conf.get('foo'))
3837
3426
def test_get_default_list_empty(self):
3838
3427
self.register_list_option('foo', '')
3839
conf = self.get_conf('')
3840
self.assertEquals([], conf.get('foo'))
3428
self.assertEquals([], self.conf.get('foo'))
3842
3430
def test_get_default_list_from_env(self):
3843
3431
self.register_list_option('foo', default_from_env=['FOO'])
3844
3432
self.overrideEnv('FOO', '')
3845
conf = self.get_conf('')
3846
self.assertEquals([], conf.get('foo'))
3433
self.assertEquals([], self.conf.get('foo'))
3848
3435
def test_get_with_list_converter_no_item(self):
3849
3436
self.register_list_option('foo', None)
3850
conf = self.get_conf('foo=,')
3851
self.assertEquals([], conf.get('foo'))
3437
self.conf.store._load_from_string('foo=,')
3438
self.assertEquals([], self.conf.get('foo'))
3853
3440
def test_get_with_list_converter_many_items(self):
3854
3441
self.register_list_option('foo', None)
3855
conf = self.get_conf('foo=m,o,r,e')
3856
self.assertEquals(['m', 'o', 'r', 'e'], conf.get('foo'))
3442
self.conf.store._load_from_string('foo=m,o,r,e')
3443
self.assertEquals(['m', 'o', 'r', 'e'], self.conf.get('foo'))
3858
3445
def test_get_with_list_converter_embedded_spaces_many_items(self):
3859
3446
self.register_list_option('foo', None)
3860
conf = self.get_conf('foo=" bar", "baz "')
3861
self.assertEquals([' bar', 'baz '], conf.get('foo'))
3447
self.conf.store._load_from_string('foo=" bar", "baz "')
3448
self.assertEquals([' bar', 'baz '], self.conf.get('foo'))
3863
3450
def test_get_with_list_converter_stripped_spaces_many_items(self):
3864
3451
self.register_list_option('foo', None)
3865
conf = self.get_conf('foo= bar , baz ')
3866
self.assertEquals(['bar', 'baz'], conf.get('foo'))
3452
self.conf.store._load_from_string('foo= bar , baz ')
3453
self.assertEquals(['bar', 'baz'], self.conf.get('foo'))
3869
3456
class TestIterOptionRefs(tests.TestCase):
4901
4451
self.assertEquals((None, None), (realname, address))
4904
class EmailOptionTests(tests.TestCase):
4906
def test_default_email_uses_BZR_EMAIL(self):
4907
conf = config.MemoryStack('email=jelmer@debian.org')
4908
# BZR_EMAIL takes precedence over EMAIL
4909
self.overrideEnv('BZR_EMAIL', 'jelmer@samba.org')
4910
self.overrideEnv('EMAIL', 'jelmer@apache.org')
4911
self.assertEquals('jelmer@samba.org', conf.get('email'))
4913
def test_default_email_uses_EMAIL(self):
4914
conf = config.MemoryStack('')
4915
self.overrideEnv('BZR_EMAIL', None)
4916
self.overrideEnv('EMAIL', 'jelmer@apache.org')
4917
self.assertEquals('jelmer@apache.org', conf.get('email'))
4919
def test_BZR_EMAIL_overrides(self):
4920
conf = config.MemoryStack('email=jelmer@debian.org')
4921
self.overrideEnv('BZR_EMAIL', 'jelmer@apache.org')
4922
self.assertEquals('jelmer@apache.org', conf.get('email'))
4923
self.overrideEnv('BZR_EMAIL', None)
4924
self.overrideEnv('EMAIL', 'jelmer@samba.org')
4925
self.assertEquals('jelmer@debian.org', conf.get('email'))
4928
class MailClientOptionTests(tests.TestCase):
4930
def test_default(self):
4931
conf = config.MemoryStack('')
4932
client = conf.get('mail_client')
4933
self.assertIs(client, mail_client.DefaultMail)
4935
def test_evolution(self):
4936
conf = config.MemoryStack('mail_client=evolution')
4937
client = conf.get('mail_client')
4938
self.assertIs(client, mail_client.Evolution)
4940
def test_kmail(self):
4941
conf = config.MemoryStack('mail_client=kmail')
4942
client = conf.get('mail_client')
4943
self.assertIs(client, mail_client.KMail)
4945
def test_mutt(self):
4946
conf = config.MemoryStack('mail_client=mutt')
4947
client = conf.get('mail_client')
4948
self.assertIs(client, mail_client.Mutt)
4950
def test_thunderbird(self):
4951
conf = config.MemoryStack('mail_client=thunderbird')
4952
client = conf.get('mail_client')
4953
self.assertIs(client, mail_client.Thunderbird)
4955
def test_explicit_default(self):
4956
conf = config.MemoryStack('mail_client=default')
4957
client = conf.get('mail_client')
4958
self.assertIs(client, mail_client.DefaultMail)
4960
def test_editor(self):
4961
conf = config.MemoryStack('mail_client=editor')
4962
client = conf.get('mail_client')
4963
self.assertIs(client, mail_client.Editor)
4965
def test_mapi(self):
4966
conf = config.MemoryStack('mail_client=mapi')
4967
client = conf.get('mail_client')
4968
self.assertIs(client, mail_client.MAPIClient)
4970
def test_xdg_email(self):
4971
conf = config.MemoryStack('mail_client=xdg-email')
4972
client = conf.get('mail_client')
4973
self.assertIs(client, mail_client.XDGEmail)
4975
def test_unknown(self):
4976
conf = config.MemoryStack('mail_client=firebird')
4977
self.assertRaises(errors.ConfigOptionValueError, conf.get,