Example #1
0
 def test_set_option(self):
     result = ini.set_option(self.tfile.name, {
         'SectionB': {
             'test3': 'new value 3B',
             'test_set_option': 'test_set_value'
         },
         'SectionD': {
             'test_set_option2': 'test_set_value1'
         }
     })
     self.assertEqual(result['changes'], {
         'SectionB': {'test3': {'after': 'new value 3B',
                                'before': 'value 3B'},
                      'test_set_option': {'after': 'test_set_value',
                                          'before': None}
         },
         'SectionD': {'test_set_option2': {'after': 'test_set_value1',
                                           'before': None}
         }
     })
     # Check existing option updated
     self.assertEqual(
         ini.get_option(self.tfile.name, 'SectionB', 'test3'),
         'new value 3B')
     # Check new section and option added
     self.assertEqual(
         ini.get_option(self.tfile.name, 'SectionD', 'test_set_option2'),
         'test_set_value1')
Example #2
0
 def test_set_option(self):
     result = ini.set_option(self.tfile.name, {
         'SectionB': {
             'test3': 'new value 3B',
             'test_set_option': 'test_set_value'
         },
         'SectionD': {
             'test_set_option2': 'test_set_value1'
         }
     })
     self.assertEqual(result['changes'], {
         'SectionB': {'test3': {'after': 'new value 3B',
                                'before': 'value 3B'},
                      'test_set_option': {'after': 'test_set_value',
                                          'before': None}
         },
         'SectionD': {'test_set_option2': {'after': 'test_set_value1',
                                           'before': None}
         }
     })
     # Check existing option updated
     self.assertEqual(
         ini.get_option(self.tfile.name, 'SectionB', 'test3'),
         'new value 3B')
     # Check new section and option added
     self.assertEqual(
         ini.get_option(self.tfile.name, 'SectionD', 'test_set_option2'),
         'test_set_value1')
Example #3
0
 def test_get_option(self):
     self.assertEqual(ini.get_option(self.tfile.name, 'main', 'test1'),
                      'value 1')
     self.assertEqual(ini.get_option(self.tfile.name, 'main', 'test2'),
                      'value 2')
     self.assertEqual(ini.get_option(self.tfile.name, 'SectionB', 'test1'),
                      'value 1B')
     self.assertEqual(ini.get_option(self.tfile.name, 'SectionB', 'test3'),
                      'value 3B')
     self.assertEqual(
         ini.get_option(self.tfile.name, 'SectionC', 'empty_option'), '')
Example #4
0
 def test_get_option(self):
     """
     Test get_option method.
     """
     self.assertEqual(ini.get_option(self.tfile.name, "main", "test1"), "value 1")
     self.assertEqual(ini.get_option(self.tfile.name, "main", "test2"), "value 2")
     self.assertEqual(
         ini.get_option(self.tfile.name, "SectionB", "test1"), "value 1B"
     )
     self.assertEqual(
         ini.get_option(self.tfile.name, "SectionB", "test3"), "value 3B"
     )
     self.assertEqual(
         ini.get_option(self.tfile.name, "SectionC", "empty_option"), ""
     )
Example #5
0
 def test_get_option(self):
     self.assertEqual(
         ini.get_option(self.tfile.name, 'main', 'test1'),
         'value 1')
     self.assertEqual(
         ini.get_option(self.tfile.name, 'main', 'test2'),
         'value 2')
     self.assertEqual(
         ini.get_option(self.tfile.name, 'SectionB', 'test1'),
         'value 1B')
     self.assertEqual(
         ini.get_option(self.tfile.name, 'SectionB', 'test3'),
         'value 3B')
     self.assertEqual(
         ini.get_option(self.tfile.name, 'SectionC', 'empty_option'),
         '')
Example #6
0
 def test_remove_option(self):
     """
     Test remove_option method.
     """
     self.assertEqual(
         ini.remove_option(self.tfile.name, "SectionB", "test1"), "value 1B"
     )
     self.assertIsNone(ini.get_option(self.tfile.name, "SectionB", "test1"))
Example #7
0
 def test_remove_option(self):
     '''
     Test remove_option method.
     '''
     self.assertEqual(
         ini.remove_option(self.tfile.name, 'SectionB', 'test1'),
         'value 1B')
     self.assertIsNone(ini.get_option(self.tfile.name, 'SectionB', 'test1'))
Example #8
0
 def test_set_option(self):
     """
     Test set_option method.
     """
     result = ini.set_option(
         self.tfile.name,
         {
             "SectionB": {
                 "test3": "new value 3B",
                 "test_set_option": "test_set_value",
             },
             "SectionD": {"test_set_option2": "test_set_value1"},
         },
     )
     self.assertEqual(
         result,
         {
             "SectionB": {
                 "test3": {"after": "new value 3B", "before": "value 3B"},
                 "test_set_option": {"after": "test_set_value", "before": None},
             },
             "SectionD": {
                 "after": {"test_set_option2": "test_set_value1"},
                 "before": None,
             },
         },
     )
     # Check existing option updated
     self.assertEqual(
         ini.get_option(self.tfile.name, "SectionB", "test3"), "new value 3B"
     )
     # Check new section and option added
     self.assertEqual(
         ini.get_option(self.tfile.name, "SectionD", "test_set_option2"),
         "test_set_value1",
     )
Example #9
0
 def test_remove_option(self):
     self.assertEqual(
         ini.remove_option(self.tfile.name, 'SectionB', 'test1'),
         'value 1B')
     self.assertIsNone(ini.get_option(self.tfile.name, 'SectionB', 'test1'))