get_value is None
This commit is contained in:
parent
bf22eab624
commit
263ceae6a1
1 changed files with 7 additions and 7 deletions
|
@ -1,7 +1,8 @@
|
||||||
from .custom import CustomOption
|
from .custom import CustomOption
|
||||||
|
|
||||||
from pathlib import Path
|
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 os.path import isfile, join, isdir, dirname
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from json import load, dump
|
from json import load, dump
|
||||||
|
@ -23,7 +24,7 @@ dico_dirs = Path('../rougail/tests/dictionaries')
|
||||||
#test_ok = [dico_dirs / env_test_folder]
|
#test_ok = [dico_dirs / env_test_folder]
|
||||||
|
|
||||||
#let's save the original environment
|
#let's save the original environment
|
||||||
save = environ.copy()
|
save = os.environ.copy()
|
||||||
|
|
||||||
test_ok = set()
|
test_ok = set()
|
||||||
excludes = set()
|
excludes = set()
|
||||||
|
@ -37,7 +38,6 @@ test_ok = list(test_ok)
|
||||||
test_ok.sort()
|
test_ok.sort()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@fixture(scope="module", params=test_ok)
|
@fixture(scope="module", params=test_ok)
|
||||||
def test_dir(request):
|
def test_dir(request):
|
||||||
return request.param
|
return request.param
|
||||||
|
@ -80,9 +80,10 @@ def test_dictionaries_warning(test_dir):
|
||||||
with open(Path('tests') / 'envvars' / current_dirname / 'makedict' / 'all.env') as json_file:
|
with open(Path('tests') / 'envvars' / current_dirname / 'makedict' / 'all.env') as json_file:
|
||||||
expected = load(json_file)
|
expected = load(json_file)
|
||||||
# here is the effective test
|
# here is the effective test
|
||||||
|
config_dict = dict(option_value(config.value.get()))
|
||||||
assert expected == config_dict
|
assert expected == config_dict
|
||||||
#teardown: set the original environement again
|
#teardown: set the original environement again
|
||||||
environ = save
|
os.environ = save.copy()
|
||||||
|
|
||||||
|
|
||||||
def populate(dest_dir, rougailconfig):
|
def populate(dest_dir, rougailconfig):
|
||||||
|
@ -97,13 +98,12 @@ def populate(dest_dir, rougailconfig):
|
||||||
root_config = config.unrestraint
|
root_config = config.unrestraint
|
||||||
else:
|
else:
|
||||||
root_config = config.unrestraint.value.mandatory()
|
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():
|
if not environment_file.is_file():
|
||||||
with environment_file.open('w') as envfh:
|
with environment_file.open('w') as envfh:
|
||||||
envfh.write('\n'.join(values) + '\n')
|
envfh.write('\n'.join(values) + '\n')
|
||||||
if not makedict_file.is_file():
|
if not makedict_file.is_file():
|
||||||
with makedict_file.open('w') as envfh:
|
with makedict_file.open('w') as envfh:
|
||||||
#envfh.write('\n'.join(values) + '\n')
|
|
||||||
config_dict = dict(option_value(config.value.get()))
|
config_dict = dict(option_value(config.value.get()))
|
||||||
dump(config_dict, envfh, indent=4)
|
dump(config_dict, envfh, indent=4)
|
||||||
envfh.write('\n')
|
envfh.write('\n')
|
||||||
|
|
Loading…
Reference in a new issue