示例#1
0
    def test_load(self, open_mock):
        context_manager_mock = mock.Mock()
        open_mock.return_value = context_manager_mock
        file_mock = mock.Mock()
        iter_mock = mock.Mock()
        iter_mock.return_value = iter(
            self._split_but_keep_seperated(mock_ini_data, '\n'))
        enter_mock = mock.Mock()
        enter_mock.return_value = file_mock
        exit_mock = mock.Mock()
        setattr(context_manager_mock, '__enter__', enter_mock)
        setattr(context_manager_mock, '__exit__', exit_mock)
        setattr(file_mock, '__iter__', iter_mock)

        ini_file = Ini()
        ini_file.load()
        result = {}
        result['test'] = [None, 'wizard']
        result['castSpell'] = [None, True]
        result['punch'] = [None, 1]
        result['ghost'] = ['section', False]
        result_sections = {}
        result_sections['section'] = set()
        result_sections['section'].add('ghost')

        self.assertEqual(ini_file._settings, result)
        self.assertEqual(ini_file._sections._sections, result_sections)
示例#2
0
from ini_handler.vbini import Ini

if __name__ == '__main__':
    ini_file = Ini()
    ini_file.load()
    print(ini_file._settings)
    print(ini_file._sections)
    print(ini_file['test'])