@@ -460,6 +460,15 @@ def test_set_xtype_bad():
460460 (["--mud" , "2.5" ], 2.5 ),
461461 # C2: user provides a z-scan file, expect to estimate through the file
462462 (["--z-scan-file" , "test_dir/testfile.xy" ], 3 ),
463+ # C3: user specifies sample composition, energy,
464+ # and sample mass density,
465+ # both with and without whitespaces, expect to estimate theoretically
466+ (["--theoretical-from-density" , "ZrO2,17.45,1.2" ], 1.49 ),
467+ (["--theoretical-from-density" , "ZrO2, 17.45, 1.2" ], 1.49 ),
468+ # C4: user specifies sample composition, energy, and packing fraction
469+ # both with and without whitespaces, expect to estimate theoretically
470+ # (["--theoretical-from-packing", "ZrO2,17.45,0.3"], 1.49),
471+ # (["--theoretical-from-packing", "ZrO2, 17.45, 0.3"], 1.49),
463472 ],
464473)
465474def test_set_mud (user_filesystem , inputs , expected_mud ):
@@ -483,6 +492,58 @@ def test_set_mud(user_filesystem, inputs, expected_mud):
483492 "Cannot find invalid file. Please specify a valid file path." ,
484493 ],
485494 ),
495+ # C2.1: (sample mass density option)
496+ # user provides fewer than three input values
497+ # expect ValueError with a message indicating the correct format
498+ (
499+ ["--theoretical-from-density" , "ZrO2,0.5" ],
500+ [
501+ ValueError ,
502+ "Invalid mu*D input 'ZrO2,0.5'. "
503+ "Expected format is 'sample composition, energy, "
504+ "sample mass density or packing fraction' "
505+ "(e.g., 'ZrO2,17.45,0.5')." ,
506+ ],
507+ ),
508+ # C2.2: (packing fraction option)
509+ # user provides fewer than three input values
510+ # expect ValueError with a message indicating the correct format
511+ (
512+ ["--theoretical-from-packing" , "ZrO2,0.5" ],
513+ [
514+ ValueError ,
515+ "Invalid mu*D input 'ZrO2,0.5'. "
516+ "Expected format is 'sample composition, energy, "
517+ "sample mass density or packing fraction' "
518+ "(e.g., 'ZrO2,17.45,0.5')." ,
519+ ],
520+ ),
521+ # C3.1: (sample mass density option)
522+ # user provides more than 3 input values
523+ # expect ValueError with a message indicating the correct format
524+ (
525+ ["--theoretical-from-density" , "ZrO2,17.45,1.5,0.5" ],
526+ [
527+ ValueError ,
528+ "Invalid mu*D input 'ZrO2,17.45,1.5,0.5'. "
529+ "Expected format is 'sample composition, energy, "
530+ "sample mass density or packing fraction' "
531+ "(e.g., 'ZrO2,17.45,0.5')." ,
532+ ],
533+ ),
534+ # C3.2: (packing fraction option)
535+ # user provides more than 3 input values
536+ # expect ValueError with a message indicating the correct format
537+ (
538+ ["--theoretical-from-packing" , "ZrO2,17.45,1.5,0.5" ],
539+ [
540+ ValueError ,
541+ "Invalid mu*D input 'ZrO2,17.45,1.5,0.5'. "
542+ "Expected format is 'sample composition, energy, "
543+ "sample mass density or packing fraction' "
544+ "(e.g., 'ZrO2,17.45,0.5')." ,
545+ ],
546+ ),
486547 ],
487548)
488549def test_set_mud_bad (user_filesystem , inputs , expected ):
@@ -491,7 +552,7 @@ def test_set_mud_bad(user_filesystem, inputs, expected):
491552 os .chdir (cwd )
492553 cli_inputs = ["data.xy" ] + inputs
493554 actual_args = get_args (cli_inputs )
494- with pytest .raises (expected_error , match = expected_error_msg ):
555+ with pytest .raises (expected_error , match = re . escape ( expected_error_msg ) ):
495556 actual_args = set_mud (actual_args )
496557
497558
0 commit comments