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