@@ -857,7 +857,7 @@ def test_parsing_environment_variables_with_unknown_argument_terminate_execution
857857
858858
859859def test_parsing_environment_variables_with_long_and_short_names_for_arguments_in_root_parsing_manager (
860- root_config_parsing_manager_with_mandatory_and_optional_arguments , test_files_path ):
860+ empty_cli_configuration , root_config_parsing_manager_with_mandatory_and_optional_arguments , test_files_path ):
861861 """
862862 Test that a configuration defined via environment variables with long and short names for arguments is correctly
863863 parsed
@@ -882,7 +882,7 @@ def test_parsing_environment_variables_with_long_and_short_names_for_arguments_i
882882
883883
884884def test_parsing_environment_variables_with_no_argument_with_default_value_in_root_parsing_manager (
885- root_config_parsing_manager_with_mandatory_and_optional_arguments ):
885+ empty_cli_configuration , root_config_parsing_manager_with_mandatory_and_optional_arguments ):
886886 """
887887 Test that the parsing of a configuration defined via environment variables missing arguments with
888888 default values results in a dict with the default values for those arguments
@@ -934,12 +934,12 @@ def test_configuration_priority_between_cli_and_environment_variables_in_root_pa
934934def test_configuration_priority_between_cli_and_configuration_file_in_root_parsing_manager (config_file ,
935935 cli_configuration ,
936936 root_config_parsing_manager_with_mandatory_and_optional_arguments ,
937- test_files_path ):
937+ test_files_path ,
938+ monkeypatch ):
938939 """
939940 Test that arguments values defined via the CLI are preserved regarding values defined via a configuration file
940941 """
941- sys .argv .append ('--config-file' )
942- sys .argv .append (test_files_path + '/root_manager_basic_configuration.json' )
942+ monkeypatch .setattr (sys , 'argv' , [* sys .argv , '--config-file' , test_files_path + '/root_manager_basic_configuration.json' ])
943943
944944 expected_dict = load_configuration_from_json_file (config_file )
945945 expected_dict ["arg5" ] = "this is a value" # This value is not defined by the CLI but it has to be present
@@ -950,8 +950,8 @@ def test_configuration_priority_between_cli_and_configuration_file_in_root_parsi
950950
951951
952952def test_configuration_priority_between_environment_variables_and_configuration_file_in_root_parsing_manager (
953- root_config_parsing_manager_with_mandatory_and_optional_arguments ,
954- test_files_path ):
953+ empty_cli_configuration , root_config_parsing_manager_with_mandatory_and_optional_arguments ,
954+ test_files_path , monkeypatch ):
955955 """
956956 Test that arguments values defined via environment variables are preserved regarding values defined via
957957 a configuration file
@@ -964,9 +964,7 @@ def test_configuration_priority_between_environment_variables_and_configuration_
964964 group_arguments_prefix = root_config_parsing_manager_with_mandatory_and_optional_arguments .cli_parser .
965965 get_groups_prefixes ())
966966
967- sys .argv = []
968- sys .argv .append ('--config-file' )
969- sys .argv .append (test_files_path + '/root_manager_basic_configuration.json' )
967+ monkeypatch .setattr (sys , 'argv' , [* sys .argv , '--config-file' , test_files_path + '/root_manager_basic_configuration.json' ])
970968
971969 expected_dict = load_configuration_from_json_file (config_file_environment_variables )
972970 expected_dict ["arg5" ] = "this is a value" # This value is not defined by the CLI but it has to be present
@@ -975,15 +973,13 @@ def test_configuration_priority_between_environment_variables_and_configuration_
975973
976974 assert result == expected_dict
977975
978- sys .argv = []
979-
980976 remove_environment_variables_configuration (variables_names = created_environment_variables )
981977
982978
983979@pytest .mark .parametrize ('config_file' , ['root_manager_basic_configuration_with_no_argument_with_default_value.json' ])
984980def test_configuration_priority_between_cli_environment_variables_and_configuration_file_in_root_parsing_manager (
985981 config_file , cli_configuration , root_config_parsing_manager_with_mandatory_and_optional_arguments ,
986- test_files_path ):
982+ test_files_path , monkeypatch ):
987983 """
988984 Test the following argument definition priority:
989985 1. CLI
@@ -999,8 +995,7 @@ def test_configuration_priority_between_cli_environment_variables_and_configurat
999995 group_arguments_prefix = root_config_parsing_manager_with_mandatory_and_optional_arguments .cli_parser .
1000996 get_groups_prefixes ())
1001997
1002- sys .argv .append ('--config-file' )
1003- sys .argv .append (test_files_path + '/root_manager_basic_configuration.json' )
998+ monkeypatch .setattr (sys , 'argv' , [* sys .argv , '--config-file' , test_files_path + '/root_manager_basic_configuration.json' ])
1004999
10051000 expected_dict = load_configuration_from_json_file (config_file )
10061001 expected_dict ["arg5" ] = "this is a value 3"
@@ -1009,13 +1004,11 @@ def test_configuration_priority_between_cli_environment_variables_and_configurat
10091004
10101005 assert result == expected_dict
10111006
1012- sys .argv = []
1013-
10141007 remove_environment_variables_configuration (variables_names = created_environment_variables )
10151008
10161009
10171010def test_parsing_environment_variables_with_subgroups_in_root_parsing_manager (
1018- root_config_parsing_manager_with_mandatory_and_optional_arguments , test_files_path ):
1011+ empty_cli_configuration , root_config_parsing_manager_with_mandatory_and_optional_arguments , test_files_path ):
10191012 """
10201013 Test that a configuration defined via environment variables with subgroups is correctly parsed
10211014 """
@@ -1037,7 +1030,7 @@ def test_parsing_environment_variables_with_subgroups_in_root_parsing_manager(
10371030
10381031
10391032def test_parsing_environment_variables_with_subgroups_and_long_and_short_names_in_root_parsing_manager (
1040- root_config_parsing_manager_with_mandatory_and_optional_arguments , test_files_path ):
1033+ empty_cli_configuration , root_config_parsing_manager_with_mandatory_and_optional_arguments , test_files_path ):
10411034 """
10421035 Test that a configuration defined via environment variables with subgroups is correctly parsed
10431036 """
@@ -1084,7 +1077,7 @@ def test_parsing_environment_variables_with_subgroups_and_unknown_arguments_term
10841077
10851078
10861079def test_parsing_environment_variables_with_subgroups_and_no_arguments_with_default_value_in_root_parsing_manager (
1087- root_config_parsing_manager_with_mandatory_and_optional_arguments , test_files_path ):
1080+ empty_cli_configuration , root_config_parsing_manager_with_mandatory_and_optional_arguments , test_files_path ):
10881081 """
10891082 Test that a configuration defined via environment variables with subgroups without variables with default values
10901083 is correctly parsed
@@ -1136,7 +1129,7 @@ def test_parsing_environment_variables_with_subgroups_and_wrong_type_terminate_e
11361129 ['root_manager_configuration_with_subgroups_and_no_argument_default_value.json' ])
11371130def test_config_priority_between_cli_environ_variables_and_configuration_file_with_subgroups_in_root_parsing_manager (
11381131 config_file , cli_configuration , root_config_parsing_manager_with_mandatory_and_optional_arguments ,
1139- test_files_path ):
1132+ test_files_path , monkeypatch ):
11401133 """
11411134 Test the following argument definition priority for a configuration with subgroups:
11421135 1. CLI
@@ -1152,8 +1145,7 @@ def test_config_priority_between_cli_environ_variables_and_configuration_file_wi
11521145 group_arguments_prefix = root_config_parsing_manager_with_mandatory_and_optional_arguments .cli_parser .
11531146 get_groups_prefixes ())
11541147
1155- sys .argv .append ('--config-file' )
1156- sys .argv .append (test_files_path + '/root_manager_configuration_with_subgroups.json' )
1148+ monkeypatch .setattr (sys , 'argv' , [* sys .argv , '--config-file' , test_files_path + '/root_manager_configuration_with_subgroups.json' ])
11571149
11581150 expected_dict = load_configuration_from_json_file (config_file )
11591151 expected_dict ['input' ]['in1' ]['name' ] = 'i1_name'
@@ -1164,8 +1156,6 @@ def test_config_priority_between_cli_environ_variables_and_configuration_file_wi
11641156
11651157 assert result == expected_dict
11661158
1167- sys .argv = []
1168-
11691159 remove_environment_variables_configuration (variables_names = created_environment_variables )
11701160
11711161
@@ -1196,22 +1186,19 @@ def test_config_priority_between_cli_and_environ_variables_with_subgroups_in_roo
11961186
11971187 assert result == expected_dict
11981188
1199- sys .argv = []
1200-
12011189 remove_environment_variables_configuration (variables_names = created_environment_variables )
12021190
12031191
12041192@pytest .mark .parametrize ('config_file' ,
12051193 ['root_manager_configuration_with_subgroups_and_no_argument_default_value.json' ])
12061194def test_config_priority_between_cli_and_configuration_file_with_subgroups_in_root_parsing_manager (
12071195 config_file , cli_configuration , root_config_parsing_manager_with_mandatory_and_optional_arguments ,
1208- test_files_path ):
1196+ test_files_path , monkeypatch ):
12091197 """
12101198 Test that arguments values defined via the CLI are preserved regarding values defined via a config file
12111199 with subgroups in configuration
12121200 """
1213- sys .argv .append ('--config-file' )
1214- sys .argv .append (test_files_path + '/root_manager_configuration_with_subgroups.json' )
1201+ monkeypatch .setattr (sys , 'argv' , [* sys .argv , '--config-file' , test_files_path + '/root_manager_configuration_with_subgroups.json' ])
12151202
12161203 expected_dict = load_configuration_from_json_file (config_file )
12171204 expected_dict ['input' ]['in1' ]['name' ] = 'in1_name'
@@ -1222,12 +1209,10 @@ def test_config_priority_between_cli_and_configuration_file_with_subgroups_in_ro
12221209
12231210 assert result == expected_dict
12241211
1225- sys .argv = []
1226-
12271212
12281213def test_config_priority_between_environ_variables_and_configuration_file_with_subgroups_in_root_parsing_manager (
12291214 root_config_parsing_manager_with_mandatory_and_optional_arguments ,
1230- test_files_path ):
1215+ test_files_path , monkeypatch ):
12311216 """
12321217 Test that arguments values defined via the environment variables are preserved regarding values defined via a config
12331218 file with subgroups in configuration
@@ -1241,9 +1226,7 @@ def test_config_priority_between_environ_variables_and_configuration_file_with_s
12411226 group_arguments_prefix = root_config_parsing_manager_with_mandatory_and_optional_arguments .cli_parser .
12421227 get_groups_prefixes ())
12431228
1244- sys .argv .append ('--config-file' )
1245-
1246- sys .argv .append (test_files_path + '/root_manager_configuration_with_subgroups_and_long_and_short_names.json' )
1229+ monkeypatch .setattr (sys , 'argv' , ['--config-file' , test_files_path + '/root_manager_configuration_with_subgroups_and_long_and_short_names.json' ])
12471230
12481231 expected_dict = load_configuration_from_json_file (config_file_environment_variables )
12491232 expected_dict ['input' ]['in1' ]['name' ] = 'i1_name'
@@ -1254,8 +1237,6 @@ def test_config_priority_between_environ_variables_and_configuration_file_with_s
12541237
12551238 assert result == expected_dict
12561239
1257- sys .argv = []
1258-
12591240 remove_environment_variables_configuration (variables_names = created_environment_variables )
12601241
12611242
0 commit comments