@@ -1453,16 +1453,19 @@ class Outputs(ShellOutputs):
14531453@shell .define
14541454class SimpleXor (ShellDef ["SimpleTaskXor.Outputs" ]):
14551455
1456- input_1 : str = shell .arg (
1456+ input_1 : str | None = shell .arg (
1457+ default = None ,
14571458 help = "help" ,
14581459 xor = ("input_1" , "input_2" , "input_3" ),
14591460 )
1460- input_2 : bool = shell .arg (
1461+ input_2 : bool | None = shell .arg (
1462+ default = None ,
14611463 help = "help" ,
14621464 argstr = "--i2" ,
14631465 xor = ("input_1" , "input_2" , "input_3" ),
14641466 )
1465- input_3 : bool = shell .arg (
1467+ input_3 : bool | None = shell .arg (
1468+ default = None ,
14661469 help = "help" ,
14671470 xor = ("input_1" , "input_2" , "input_3" ),
14681471 )
@@ -1478,29 +1481,24 @@ def test_task_inputs_mandatory_with_xOR_one_mandatory_is_OK():
14781481 """input definition with mandatory inputs"""
14791482 simple_xor = SimpleXor ()
14801483 simple_xor .input_1 = "Input1"
1481- simple_xor .input_2 = attrs .NOTHING
14821484 simple_xor ._check_rules ()
14831485
14841486
14851487def test_task_inputs_mandatory_with_xOR_one_mandatory_out_3_is_OK ():
14861488 """input definition with mandatory inputs"""
14871489 simple_xor = SimpleXor ()
1488- simple_xor .input_1 = attrs .NOTHING
1489- simple_xor .input_2 = attrs .NOTHING
14901490 simple_xor .input_3 = True
14911491 simple_xor ._check_rules ()
14921492
14931493
14941494def test_task_inputs_mandatory_with_xOR_zero_mandatory_raises_error ():
14951495 """input definition with mandatory inputs"""
14961496 simple_xor = SimpleXor ()
1497- simple_xor .input_1 = attrs .NOTHING
1498- simple_xor .input_2 = attrs .NOTHING
1499- with pytest .raises (Exception ) as excinfo :
1497+ simple_xor .input_2 = False
1498+ with pytest .raises (
1499+ ValueError , match = "At least one of the mutually exclusive fields"
1500+ ):
15001501 simple_xor ._check_rules ()
1501- assert "input_1 is mandatory" in str (excinfo .value )
1502- assert "no alternative provided by ['input_2', 'input_3']" in str (excinfo .value )
1503- assert excinfo .type is AttributeError
15041502
15051503
15061504def test_task_inputs_mandatory_with_xOR_two_mandatories_raises_error ():
@@ -1509,10 +1507,10 @@ def test_task_inputs_mandatory_with_xOR_two_mandatories_raises_error():
15091507 simple_xor .input_1 = "Input1"
15101508 simple_xor .input_2 = True
15111509
1512- with pytest .raises (Exception ) as excinfo :
1510+ with pytest .raises (
1511+ ValueError , match = "Mutually exclusive fields .* are set together"
1512+ ):
15131513 simple_xor ._check_rules ()
1514- assert "input_1 is mutually exclusive with ['input_2']" in str (excinfo .value )
1515- assert excinfo .type is AttributeError
15161514
15171515
15181516def test_task_inputs_mandatory_with_xOR_3_mandatories_raises_error ():
@@ -1522,9 +1520,8 @@ def test_task_inputs_mandatory_with_xOR_3_mandatories_raises_error():
15221520 simple_xor .input_2 = True
15231521 simple_xor .input_3 = False
15241522
1525- with pytest .raises (Exception ) as excinfo :
1523+ with pytest .raises (
1524+ ValueError ,
1525+ match = r".*Mutually exclusive fields \(input_1='Input1', input_2=True\) are set together" ,
1526+ ):
15261527 simple_xor ._check_rules ()
1527- assert "input_1 is mutually exclusive with ['input_2', 'input_3']" in str (
1528- excinfo .value
1529- )
1530- assert excinfo .type is AttributeError
0 commit comments