def test_setString_with_wild_charactes(self):
        """
        A string configuration can be set to text containing any characters.
        """
        config_file = StringIO(
            u'[section]\n'
            u'value: value\n'
            u'',
            )
        config = FileConfigurationProxy(
            configuration_file=config_file)
        config.load()

        config.setString(u'section', u'value', self.special_characters)

        self.assertEqual(
            self.special_characters,
            config.getString(u'section', u'value'))
    def test_setString_with_python_formating(self):
        """
        A string configuration can be set to a python string formatting
        expressions.
        """
        config_file = StringIO(
            u'[section]\n'
            u'value: value\n'
            u'',
            )
        config = FileConfigurationProxy(
            configuration_file=config_file)
        config.load()

        config.setString(u'section', u'value', u'do %(some)s value')

        self.assertEqual(
            u'do %(some)s value',
            config.getString(u'section', u'value'))
 def test_save(self):
     """
     System test for persisting changes into a file.
     """
     config_content = (
         u'[another_muță]\n'
         u'another_muță_option: another_muță_value\n\n')
     test_filesystem = manufacture.fs
     test_segments = None
     try:
         test_segments = test_filesystem.createFileInTemp(
             content=config_content)
         config_path = test_filesystem.getRealPathFromSegments(
             test_segments)
         with test_filesystem._impersonateUser():
             config = FileConfigurationProxy(
                 configuration_path=config_path)
             config.load()
             self.assertEqual(
                 u'another_muță_value',
                 config.getString(
                     u'another_muță',
                     u'another_muță_option'))
             config.setString(
                     u'another_muță',
                     u'another_muță_option',
                     u'muță_value',
                     )
             config.save()
             config = FileConfigurationProxy(
                 configuration_path=config_path)
             config.load()
             self.assertEqual(
                 u'muță_value',
                 config.getString(
                     u'another_muță',
                     u'another_muță_option'))
     finally:
         if test_segments:
             test_filesystem.deleteFile(test_segments, ignore_errors=True)