689
689
self.assertFileEqual(content, 'test.conf')
692
class TestIniConfigOptionExpansionDefaultValue(tests.TestCaseInTempDir):
693
"""What is the default value of expand for config options.
695
This is an opt-in beta feature used to evaluate whether or not option
696
references can appear in dangerous place raising exceptions, disapearing
697
(and as such corrupting data) or if it's safe to activate the option by
700
Note that these tests relies on config._expand_default_value being already
701
overwritten in the parent class setUp.
705
super(TestIniConfigOptionExpansionDefaultValue, self).setUp()
709
self.warnings.append(args[0] % args[1:])
710
self.overrideAttr(trace, 'warning', warning)
712
def get_config(self, expand):
713
c = config.GlobalConfig.from_string('bzr.config.expand=%s' % (expand,),
717
def assertExpandIs(self, expected):
718
actual = config._get_expand_default_value()
719
#self.config.get_user_option_as_bool('bzr.config.expand')
720
self.assertEquals(expected, actual)
722
def test_default_is_None(self):
723
self.assertEquals(None, config._expand_default_value)
725
def test_default_is_False_even_if_None(self):
726
self.config = self.get_config(None)
727
self.assertExpandIs(False)
729
def test_default_is_False_even_if_invalid(self):
730
self.config = self.get_config('<your choice>')
731
self.assertExpandIs(False)
733
# Huh ? My choice is False ? Thanks, always happy to hear that :D
734
# Wait, you've been warned !
735
self.assertLength(1, self.warnings)
737
'Value "<your choice>" is not a boolean for "bzr.config.expand"',
740
def test_default_is_True(self):
741
self.config = self.get_config(True)
742
self.assertExpandIs(True)
744
def test_default_is_False(self):
745
self.config = self.get_config(False)
746
self.assertExpandIs(False)
749
692
class TestIniConfigOptionExpansion(tests.TestCase):
750
693
"""Test option expansion from the IniConfig level.