183
183
user_global_option=something
184
184
bzr.mergetool.sometool=sometool {base} {this} {other} -o {result}
185
185
bzr.mergetool.funkytool=funkytool "arg with spaces" {this_temp}
186
bzr.mergetool.newtool='"newtool with spaces" {this_temp}'
187
186
bzr.default_mergetool=sometool
1340
1339
self.log(repr(tools))
1341
1340
self.assertEqual(
1342
1341
{u'funkytool' : u'funkytool "arg with spaces" {this_temp}',
1343
u'sometool' : u'sometool {base} {this} {other} -o {result}',
1344
u'newtool' : u'"newtool with spaces" {this_temp}'},
1342
u'sometool' : u'sometool {base} {this} {other} -o {result}'},
1347
1345
def test_get_merge_tools_empty(self):
2563
2561
class TestMutableSection(tests.TestCase):
2565
scenarios = [('mutable',
2567
lambda opts: config.MutableSection('myID', opts)},),
2570
lambda opts: config.CommandLineSection(opts)},),
2563
# FIXME: Parametrize so that all sections (including os.environ and the
2564
# ones produced by Stores) run these tests -- vila 2011-04-01
2573
2566
def test_set(self):
2574
2567
a_dict = dict(foo='bar')
2575
section = self.get_section(a_dict)
2568
section = config.MutableSection('myID', a_dict)
2576
2569
section.set('foo', 'new_value')
2577
2570
self.assertEquals('new_value', section.get('foo'))
2578
2571
# The change appears in the shared section
2584
2577
def test_set_preserve_original_once(self):
2585
2578
a_dict = dict(foo='bar')
2586
section = self.get_section(a_dict)
2579
section = config.MutableSection('myID', a_dict)
2587
2580
section.set('foo', 'first_value')
2588
2581
section.set('foo', 'second_value')
2589
2582
# We keep track of the original value
2593
2586
def test_remove(self):
2594
2587
a_dict = dict(foo='bar')
2595
section = self.get_section(a_dict)
2588
section = config.MutableSection('myID', a_dict)
2596
2589
section.remove('foo')
2597
2590
# We get None for unknown options via the default value
2598
2591
self.assertEquals(None, section.get('foo'))
2606
2599
def test_remove_new_option(self):
2607
2600
a_dict = dict()
2608
section = self.get_section(a_dict)
2601
section = config.MutableSection('myID', a_dict)
2609
2602
section.set('foo', 'bar')
2610
2603
section.remove('foo')
2611
2604
self.assertFalse('foo' in section.options)
2615
2608
self.assertEquals(config._NewlyCreatedOption, section.orig['foo'])
2618
class TestCommandLineSection(tests.TestCase):
2621
super(TestCommandLineSection, self).setUp()
2622
self.section = config.CommandLineSection()
2624
def test_no_override(self):
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)
2630
def test_simple_override(self):
2631
self.section._from_cmdline(['a=b'])
2632
self.assertEqual('b', self.section.get('a'))
2634
def test_list_override(self):
2635
self.section._from_cmdline(['l=1,2,3'])
2636
val = self.section.get('l')
2637
self.assertEqual('1,2,3', 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))
2642
def test_multiple_overrides(self):
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'))
2647
def test_wrong_syntax(self):
2648
self.assertRaises(errors.BzrCommandError,
2649
self.section._from_cmdline, ['a=b', 'c'])
2652
2611
class TestStore(tests.TestCaseWithTransport):
2654
2613
def assertSectionContent(self, expected, section):