16
16
LazyField ,
17
17
ShellOutSpec ,
18
18
)
19
- from ..task import (
20
- TaskBase ,
21
- ShellCommandTask
22
- )
19
+ from ..task import TaskBase , ShellCommandTask
23
20
from ..helpers import make_klass
24
21
import pytest
25
22
import attr
26
23
24
+
27
25
def test_basespec ():
28
26
spec = BaseSpec ()
29
27
assert (
@@ -372,40 +370,43 @@ def test_input_file_hash_5(tmpdir):
372
370
hash3 = inputs (in_file = [{"file" : file_diffcontent , "int" : 3 }]).hash
373
371
assert hash1 != hash3
374
372
373
+
375
374
class SimpleTask (ShellCommandTask ):
376
- input_fields = [
377
- (
378
- "input_1" ,
379
- str ,
380
- {
381
- "help_string" : "help" ,
382
- "mandatory" : True ,
383
- "xor" : ("input_1" , "input_2" , "input_3" ),
384
- }
385
- ),
386
- (
387
- "input_2" ,
388
- bool ,
389
- {
390
- "help_string" : "help" ,
391
- "mandatory" : True ,
392
- "argstr" : "--i2" ,
393
- "xor" : ("input_1" , "input_2" , "input_3" ),
394
- }
395
- ),
396
- (
397
- "input_3" ,
398
- bool ,
399
- {
400
- "help_string" : "help" ,
401
- "mandatory" : True ,
402
- "xor" : ("input_1" , "input_2" , "input_3" ),
403
- }
404
- )
375
+ input_fields = [
376
+ (
377
+ "input_1" ,
378
+ str ,
379
+ {
380
+ "help_string" : "help" ,
381
+ "mandatory" : True ,
382
+ "xor" : ("input_1" , "input_2" , "input_3" ),
383
+ },
384
+ ),
385
+ (
386
+ "input_2" ,
387
+ bool ,
388
+ {
389
+ "help_string" : "help" ,
390
+ "mandatory" : True ,
391
+ "argstr" : "--i2" ,
392
+ "xor" : ("input_1" , "input_2" , "input_3" ),
393
+ },
394
+ ),
395
+ (
396
+ "input_3" ,
397
+ bool ,
398
+ {
399
+ "help_string" : "help" ,
400
+ "mandatory" : True ,
401
+ "xor" : ("input_1" , "input_2" , "input_3" ),
402
+ },
403
+ ),
405
404
]
406
405
task_input_spec = SpecInfo (name = "Input" , fields = input_fields , bases = (ShellSpec ,))
407
406
task_output_fields = []
408
- task_output_spec = SpecInfo (name = "Output" , fields = task_output_fields , bases = (ShellOutSpec ,))
407
+ task_output_spec = SpecInfo (
408
+ name = "Output" , fields = task_output_fields , bases = (ShellOutSpec ,)
409
+ )
409
410
410
411
input_spec = task_input_spec
411
412
output_spec = task_output_spec
@@ -415,7 +416,7 @@ class SimpleTask(ShellCommandTask):
415
416
def test_task_inputs_mandatory_with_xOR_one_mandatory_is_OK ():
416
417
"""input spec with mandatory inputs"""
417
418
task = SimpleTask ()
418
- task .inputs .input_1 = ' Input1'
419
+ task .inputs .input_1 = " Input1"
419
420
task .inputs .input_2 = attr .NOTHING
420
421
task .inputs .check_fields_input_spec ()
421
422
@@ -443,23 +444,27 @@ def test_task_inputs_mandatory_with_xOR_zero_mandatory_raises_error():
443
444
def test_task_inputs_mandatory_with_xOR_two_mandatories_raises_error ():
444
445
"""input spec with mandatory inputs"""
445
446
task = SimpleTask ()
446
- task .inputs .input_1 = ' Input1'
447
+ task .inputs .input_1 = " Input1"
447
448
task .inputs .input_2 = True
448
-
449
+
449
450
with pytest .raises (Exception ) as excinfo :
450
451
task .inputs .check_fields_input_spec ()
451
- assert "input_2 is mutually exclusive with ('input_1', 'input_2'" in str (excinfo .value )
452
+ assert "input_2 is mutually exclusive with ('input_1', 'input_2'" in str (
453
+ excinfo .value
454
+ )
452
455
assert excinfo .type is AttributeError
453
456
454
457
455
458
def test_task_inputs_mandatory_with_xOR_3_mandatories_raises_error ():
456
459
"""input spec with mandatory inputs"""
457
460
task = SimpleTask ()
458
- task .inputs .input_1 = ' Input1'
461
+ task .inputs .input_1 = " Input1"
459
462
task .inputs .input_2 = True
460
463
task .inputs .input_3 = False
461
-
464
+
462
465
with pytest .raises (Exception ) as excinfo :
463
466
task .inputs .check_fields_input_spec ()
464
- assert "input_2 is mutually exclusive with ('input_1', 'input_2', 'input_3'" in str (excinfo .value )
465
- assert excinfo .type is AttributeError
467
+ assert "input_2 is mutually exclusive with ('input_1', 'input_2', 'input_3'" in str (
468
+ excinfo .value
469
+ )
470
+ assert excinfo .type is AttributeError
0 commit comments