@@ -214,7 +214,7 @@ def test_set_output_directory_bad(user_filesystem):
214
214
# This test only checks loading behavior,
215
215
# not value validation (which is handled by `set_wavelength`).
216
216
# C1: no args, expect to update arg values from home config
217
- (["" ], {"wavelength" : 0.3 , "anode_type" : None }),
217
+ ([], {"wavelength" : 0.3 , "anode_type" : None }),
218
218
# C2: wavelength provided, expect to return args unchanged
219
219
(["--wavelength" , "0.25" ], {"wavelength" : 0.25 , "anode_type" : None }),
220
220
# C3: anode type provided, expect to return args unchanged
@@ -235,7 +235,7 @@ def test_load_wavelength_from_config_file_with_home_conf_file(
235
235
mocker .patch ("pathlib.Path.home" , lambda _ : home_dir )
236
236
os .chdir (cwd )
237
237
238
- cli_inputs = ["2.5 " , "data.xy " ] + inputs
238
+ cli_inputs = ["data.xy " , "--mud" , "2.5 " ] + inputs
239
239
actual_args = get_args (cli_inputs )
240
240
actual_args = load_wavelength_from_config_file (actual_args )
241
241
assert actual_args .wavelength == expected ["wavelength" ]
@@ -254,7 +254,7 @@ def test_load_wavelength_from_config_file_with_home_conf_file(
254
254
# This test only checks loading behavior,
255
255
# not value validation (which is handled by `set_wavelength`).
256
256
# C1: no args, expect to update arg values from local config
257
- (["" ], {"wavelength" : 0.6 , "anode_type" : None }),
257
+ ([], {"wavelength" : 0.6 , "anode_type" : None }),
258
258
# C2: wavelength provided, expect to return args unchanged
259
259
(["--wavelength" , "0.25" ], {"wavelength" : 0.25 , "anode_type" : None }),
260
260
# C3: anode type provided, expect to return args unchanged
@@ -278,7 +278,7 @@ def test_load_wavelength_from_config_file_with_local_conf_file(
278
278
with open (cwd / "diffpyconfig.json" , "w" ) as f :
279
279
json .dump (local_config_data , f )
280
280
281
- cli_inputs = ["2.5 " , "data.xy " ] + inputs
281
+ cli_inputs = ["data.xy " , "--mud" , "2.5 " ] + inputs
282
282
actual_args = get_args (cli_inputs )
283
283
actual_args = load_wavelength_from_config_file (actual_args )
284
284
assert actual_args .wavelength == expected ["wavelength" ]
@@ -299,7 +299,7 @@ def test_load_wavelength_from_config_file_with_local_conf_file(
299
299
# This test only checks loading behavior,
300
300
# not value validation (which is handled by `set_wavelength`).
301
301
# C1: no args
302
- (["" ], {"wavelength" : None , "anode_type" : None }),
302
+ ([], {"wavelength" : None , "anode_type" : None }),
303
303
# C1: wavelength provided
304
304
(["--wavelength" , "0.25" ], {"wavelength" : 0.25 , "anode_type" : None }),
305
305
# C2: anode type provided
@@ -321,7 +321,7 @@ def test_load_wavelength_from_config_file_without_conf_files(
321
321
confile = home_dir / "diffpyconfig.json"
322
322
os .remove (confile )
323
323
324
- cli_inputs = ["2.5 " , "data.xy " ] + inputs
324
+ cli_inputs = ["data.xy " , "--mud" , "2.5 " ] + inputs
325
325
actual_args = get_args (cli_inputs )
326
326
actual_args = load_wavelength_from_config_file (actual_args )
327
327
assert actual_args .wavelength == expected ["wavelength" ]
@@ -406,13 +406,13 @@ def test_set_wavelength(inputs, expected):
406
406
( # C3: invalid anode type
407
407
# expect error asking to specify a valid anode type
408
408
["--anode-type" , "invalid" ],
409
- f"Anode type not recognized. "
409
+ f"Anode type 'invalid' not recognized. "
410
410
f"Please rerun specifying an anode_type from { * known_sources , } ." ,
411
411
),
412
412
( # C4: invalid wavelength
413
413
# expect error asking to specify a valid wavelength or anode type
414
- ["--wavelength" , "0 " ],
415
- "No valid wavelength . "
414
+ ["--wavelength" , "-0.2 " ],
415
+ "Wavelength = -0.2 is not valid . "
416
416
"Please rerun specifying a known anode_type "
417
417
"or a positive wavelength." ,
418
418
),
@@ -421,6 +421,7 @@ def test_set_wavelength(inputs, expected):
421
421
def test_set_wavelength_bad (inputs , expected_error_msg ):
422
422
cli_inputs = ["data.xy" , "--mud" , "2.5" ] + inputs
423
423
actual_args = get_args (cli_inputs )
424
+ print (actual_args .wavelength )
424
425
with pytest .raises (ValueError , match = re .escape (expected_error_msg )):
425
426
actual_args = set_wavelength (actual_args )
426
427
0 commit comments