From c51db38022876a1f6f3cbc1d5787d2222c2c765c Mon Sep 17 00:00:00 2001 From: gwen Date: Tue, 1 Oct 2024 12:03:52 +0200 Subject: [PATCH] file handle --- tests/test_load.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_load.py b/tests/test_load.py index 62629f9..2cfb754 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -4,7 +4,7 @@ from pathlib import Path from os import getcwd, listdir, environ, makedirs from os.path import isfile, join, isdir, dirname from pathlib import Path -import json +from json import load, dump from pytest import fixture, raises from ruamel.yaml import YAML @@ -51,13 +51,13 @@ def _test_dictionaries(test_dir): def test_dictionaries_warning(test_dir): - "tests the '00_6string' folder" + "tests the env output" current_dirname = test_dir.name rougailconfig = _test_dictionaries(test_dir) # populate tests if not already exists dest_dir = Path('tests') / 'envvars' / test_dir.name populate(dest_dir, rougailconfig) - # loads the config in the tiramisu's meaning + # loads the config in the tiramisu's meaning config = Rougail(rougailconfig).run() #Config(optiondescription["option_0"]) config_dict = dict(config.value.get()) user_datas = {'errors': [], @@ -76,10 +76,10 @@ def test_dictionaries_warning(test_dir): new_config_dict = dict(new_config.value.get()) # expected output with open(Path('tests') / 'envvars' / current_dirname / 'makedict' / 'all.env') as json_file: - expected = json.load(json_file) + expected = load(json_file) # here is the effective test for key, value in new_config_dict.items(): - assert expected["rougail."+key.name()] == value + assert expected["rougail." + key.name()] == value def populate(dest_dir, rougailconfig): @@ -102,7 +102,7 @@ def populate(dest_dir, rougailconfig): with makedict_file.open('w') as envfh: #envfh.write('\n'.join(values) + '\n') config_dict = dict(option_value(config.value.get())) - dump(config_dict, fh, indent=4) + dump(config_dict, envfh, indent=4) envfh.write('\n')