示例#1
0
    def test_should_load_yml_file_with_malformed_syntax_and_return_empty_dict(
            self):
        create_test_malformed_yml_file()
        result = yml_load(tmp_path_malformed)

        self.assertEqual(dict, type(result))
        self.assertEqual(len(result.keys()), 0)
示例#2
0
        def test(yml_refs, value):
            append_result = yml_append(tmp_path, (yml_refs, value))
            newly_updated = yml_load(tmp_path)
            value_after_append = yml_get(tmp_path, yml_refs)

            self.assertEqual(append_result, newly_updated)
            self.assertTrue(str(value_after_append).__contains__(str(value)))
示例#3
0
    def test_yml_create_should_save_yml_file_in_pointed_localisation(self):
        path = '/tmp/example.yml'
        val = {
            'country': 'Poland',
            'continent': 'Europe',
            'other': {
                'population': 36000000,
                'language': 'polski'
            }
        }
        saved = yml_create(path, val)
        loaded_again = yml_load(path)

        self.assertEqual(val, loaded_again)
        self.assertEqual(saved.path, path)
        self.assertEqual(saved.content, yaml.dump(val))
        delete_test_yml_file(path)
示例#4
0
    def test_should_not_load_yml_file_just_not_exist(self):
        bad_path = '/not/existing/file'

        with self.assertRaises(FileNotFoundError):
            yml_load(bad_path)
示例#5
0
    def test_should_load_yml_file_with_success(self):
        result = yml_load(tmp_path)

        self.assertEqual(dict, type(result))