diff --git a/tests/test_load.py b/tests/test_load.py index da8bc92..b39f673 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -1,7 +1,8 @@ from .custom import CustomOption from pathlib import Path -from os import getcwd, listdir, environ, makedirs +from os import getcwd, listdir, makedirs +import os from os.path import isfile, join, isdir, dirname from pathlib import Path from json import load, dump @@ -23,7 +24,7 @@ dico_dirs = Path('../rougail/tests/dictionaries') #test_ok = [dico_dirs / env_test_folder] #let's save the original environment -save = environ.copy() +save = os.environ.copy() test_ok = set() excludes = set() @@ -37,7 +38,6 @@ test_ok = list(test_ok) test_ok.sort() - @fixture(scope="module", params=test_ok) def test_dir(request): return request.param @@ -76,13 +76,14 @@ def test_dictionaries_warning(test_dir): user_datas=user_datas, ) environment.run() - # expected output + #expected output with open(Path('tests') / 'envvars' / current_dirname / 'makedict' / 'all.env') as json_file: expected = load(json_file) # here is the effective test + config_dict = dict(option_value(config.value.get())) assert expected == config_dict #teardown: set the original environement again - environ = save + os.environ = save.copy() def populate(dest_dir, rougailconfig): @@ -97,13 +98,12 @@ def populate(dest_dir, rougailconfig): root_config = config.unrestraint else: root_config = config.unrestraint.value.mandatory() - values = ['ROUGAIL_' + variable.path().upper() + '="' + get_value(variable) + '"' for variable in get_variables(root_config)] + values = ['ROUGAIL_' + variable.path().upper() + '="' + "" if get_value(variable) is None else get_value(variable) + '"' for variable in get_variables(root_config)] if not environment_file.is_file(): with environment_file.open('w') as envfh: envfh.write('\n'.join(values) + '\n') if not makedict_file.is_file(): with makedict_file.open('w') as envfh: - #envfh.write('\n'.join(values) + '\n') config_dict = dict(option_value(config.value.get())) dump(config_dict, envfh, indent=4) envfh.write('\n')