@@ -372,10 +372,7 @@ def test_input_file_hash_5(tmpdir):
372
372
hash3 = inputs (in_file = [{"file" : file_diffcontent , "int" : 3 }]).hash
373
373
assert hash1 != hash3
374
374
375
-
376
-
377
- def test_task_inputs_mandatory_with_xOR_TF ():
378
- """input spec with mandatory inputs"""
375
+ class SimpleTask (ShellCommandTask ):
379
376
input_fields = [
380
377
(
381
378
"input_1" ,
@@ -401,49 +398,33 @@ def test_task_inputs_mandatory_with_xOR_TF():
401
398
task_output_fields = []
402
399
task_output_spec = SpecInfo (name = "Output" , fields = task_output_fields , bases = (ShellOutSpec ,))
403
400
404
- class MyTask (ShellCommandTask ):
405
- input_spec = task_input_spec
406
- output_spec = task_output_spec
407
- executable = "cmd"
401
+ input_spec = task_input_spec
402
+ output_spec = task_output_spec
403
+ executable = "cmd"
408
404
409
- task = MyTask ()
405
+
406
+ def test_task_inputs_mandatory_with_xOR_one_mandatory_is_enough ():
407
+ """input spec with mandatory inputs"""
408
+ task = SimpleTask ()
410
409
task .inputs .input_1 = True
411
410
task .inputs .input_2 = attr .NOTHING
412
411
task .inputs .check_fields_input_spec ()
413
412
414
- def test_task_inputs_mandatory_with_xOR_TT ():
413
+ def test_task_inputs_mandatory_with_xOR_zero_mandatory_raises_error ():
415
414
"""input spec with mandatory inputs"""
416
- input_fields = [
417
- (
418
- "input_1" ,
419
- bool ,
420
- {
421
- "help_string" : "help" ,
422
- "mandatory" : True ,
423
- "xor" : ("input_1" , "input_2" ),
424
- }
425
- ),
426
- (
427
- "input_2" ,
428
- bool ,
429
- {
430
- "help_string" : "help" ,
431
- "mandatory" : True ,
432
- "argstr" : "--i2" ,
433
- "xor" : ("input_1" , "input_2" ),
434
- }
435
- )
436
- ]
437
- task_input_spec = SpecInfo (name = "Input" , fields = input_fields , bases = (ShellSpec ,))
438
- task_output_fields = []
439
- task_output_spec = SpecInfo (name = "Output" , fields = task_output_fields , bases = (ShellOutSpec ,))
415
+ task = SimpleTask ()
416
+ task .inputs .input_1 = attr .NOTHING
417
+ task .inputs .input_2 = attr .NOTHING
418
+ task .inputs .check_fields_input_spec ()
440
419
441
- class MyTask (ShellCommandTask ):
442
- input_spec = task_input_spec
443
- output_spec = task_output_spec
444
- executable = "cmd"
445
420
446
- task = MyTask ()
421
+ def test_task_inputs_mandatory_with_xOR_two_mandatories_raises_error ():
422
+ """input spec with mandatory inputs"""
423
+ task = SimpleTask ()
447
424
task .inputs .input_1 = True
448
425
task .inputs .input_2 = True
449
- task .inputs .check_fields_input_spec ()
426
+
427
+ with pytest .raises (Exception ) as excinfo :
428
+ task .inputs .check_fields_input_spec ()
429
+ assert "input_2 is mutually exclusive with ('input_1', 'input_2')" in str (excinfo .value )
430
+ assert excinfo .type is AttributeError
0 commit comments