19
19
from cwltool .errors import WorkflowException
20
20
from cwltool .main import main
21
21
from cwltool .utils import onWindows , subprocess
22
+ from cwltool .context import RuntimeContext
22
23
23
24
from .util import (get_data , get_windows_safe_factory , needs_docker ,
24
25
needs_singularity , windows_needs_docker )
@@ -152,16 +153,21 @@ def test_factory_bad_outputs(self):
152
153
153
154
def test_default_args (self ):
154
155
f = cwltool .factory .Factory ()
155
- assert f .runtimeContext .use_container is True
156
- assert f .runtimeContext .on_error == "stop"
156
+ assert f .runtime_context .use_container is True
157
+ assert f .runtime_context .on_error == "stop"
157
158
158
159
def test_redefined_args (self ):
159
- f = cwltool .factory .Factory (use_container = False , on_error = "continue" )
160
- assert f .runtimeContext .use_container is False
161
- assert f .runtimeContext .on_error == "continue"
160
+ runtime_context = RuntimeContext ()
161
+ runtime_context .use_container = False
162
+ runtime_context .on_error = "continue"
163
+ f = cwltool .factory .Factory (runtime_context = runtime_context )
164
+ assert f .runtime_context .use_container is False
165
+ assert f .runtime_context .on_error == "continue"
162
166
163
167
def test_partial_scatter (self ):
164
- f = cwltool .factory .Factory (on_error = "continue" )
168
+ runtime_context = RuntimeContext ()
169
+ runtime_context .on_error = "continue"
170
+ f = cwltool .factory .Factory (runtime_context = runtime_context )
165
171
fail = f .make (get_data ("tests/wf/scatterfail.cwl" ))
166
172
try :
167
173
fail ()
@@ -173,7 +179,9 @@ def test_partial_scatter(self):
173
179
self .fail ("Should have raised WorkflowStatus" )
174
180
175
181
def test_partial_output (self ):
176
- f = cwltool .factory .Factory (on_error = "continue" )
182
+ runtime_context = RuntimeContext ()
183
+ runtime_context .on_error = "continue"
184
+ f = cwltool .factory .Factory (runtime_context = runtime_context )
177
185
fail = f .make (get_data ("tests/wf/wffail.cwl" ))
178
186
try :
179
187
fail ()
@@ -248,36 +256,32 @@ def loadref(base, p):
248
256
249
257
sc .sort (key = lambda k : k ["basename" ])
250
258
251
- self .assertEquals ([{
252
- "basename" : "bar.cwl" ,
253
- "nameroot" : "bar" ,
254
- "class" : "File" ,
255
- "nameext" : ".cwl" ,
256
- "location" : "file:///example/bar.cwl"
257
- },
258
- {
259
- "basename" : "data.txt" ,
260
- "nameroot" : "data" ,
261
- "class" : "File" ,
262
- "nameext" : ".txt" ,
263
- "location" : "file:///example/data.txt"
264
- },
265
- {
266
- "basename" : "data2" ,
267
- "class" : "Directory" ,
268
- "location" : "file:///example/data2" ,
269
- "listing" : [{
270
- "basename" : "data3.txt" ,
271
- "nameroot" : "data3" ,
272
- "class" : "File" ,
273
- "nameext" : ".txt" ,
274
- "location" : "file:///example/data3.txt" ,
275
- "secondaryFiles" : [{
276
- "class" : "File" ,
277
- "basename" : "data5.txt" ,
278
- "location" : "file:///example/data5.txt" ,
279
- "nameext" : ".txt" ,
280
- "nameroot" : "data5"
259
+ self .assertEquals ([
260
+ {"basename" : "bar.cwl" ,
261
+ "nameroot" : "bar" ,
262
+ "class" : "File" ,
263
+ "nameext" : ".cwl" ,
264
+ "location" : "file:///example/bar.cwl" },
265
+ {"basename" : "data.txt" ,
266
+ "nameroot" : "data" ,
267
+ "class" : "File" ,
268
+ "nameext" : ".txt" ,
269
+ "location" : "file:///example/data.txt" },
270
+ {"basename" : "data2" ,
271
+ "class" : "Directory" ,
272
+ "location" : "file:///example/data2" ,
273
+ "listing" : [
274
+ {"basename" : "data3.txt" ,
275
+ "nameroot" : "data3" ,
276
+ "class" : "File" ,
277
+ "nameext" : ".txt" ,
278
+ "location" : "file:///example/data3.txt" ,
279
+ "secondaryFiles" : [
280
+ {"class" : "File" ,
281
+ "basename" : "data5.txt" ,
282
+ "location" : "file:///example/data5.txt" ,
283
+ "nameext" : ".txt" ,
284
+ "nameroot" : "data5"
281
285
}]
282
286
}]
283
287
}, {
@@ -313,39 +317,27 @@ def test_trick_scandeps(self):
313
317
314
318
class TestDedup (unittest .TestCase ):
315
319
def test_dedup (self ):
316
- ex = [{
317
- "class" : "File" ,
318
- "location" : "file:///example/a"
319
- },
320
- {
321
- "class" : "File" ,
322
- "location" : "file:///example/a"
323
- },
324
- {
325
- "class" : "File" ,
326
- "location" : "file:///example/d"
327
- },
328
- {
329
- "class" : "Directory" ,
330
- "location" : "file:///example/c" ,
331
- "listing" : [{
332
- "class" : "File" ,
333
- "location" : "file:///example/d"
334
- }]
335
- }]
336
-
337
- self .assertEquals ([{
338
- "class" : "File" ,
339
- "location" : "file:///example/a"
340
- },
341
- {
342
- "class" : "Directory" ,
343
- "location" : "file:///example/c" ,
344
- "listing" : [{
345
- "class" : "File" ,
346
- "location" : "file:///example/d"
347
- }]
348
- }], cwltool .pathmapper .dedup (ex ))
320
+ ex = [{"class" : "File" ,
321
+ "location" : "file:///example/a" },
322
+ {"class" : "File" ,
323
+ "location" : "file:///example/a" },
324
+ {"class" : "File" ,
325
+ "location" : "file:///example/d" },
326
+ {"class" : "Directory" ,
327
+ "location" : "file:///example/c" ,
328
+ "listing" : [
329
+ {"class" : "File" ,
330
+ "location" : "file:///example/d" }]}]
331
+
332
+ self .assertEquals ([
333
+ {"class" : "File" ,
334
+ "location" : "file:///example/a" },
335
+ {"class" : "Directory" ,
336
+ "location" : "file:///example/c" ,
337
+ "listing" : [
338
+ {"class" : "File" ,
339
+ "location" : "file:///example/d" }]}],
340
+ cwltool .pathmapper .dedup (ex ))
349
341
350
342
351
343
class TestTypeCompare (unittest .TestCase ):
@@ -623,11 +615,9 @@ def test_print_dot(self):
623
615
624
616
class TestCmdLine (unittest .TestCase ):
625
617
def get_main_output (self , new_args ):
626
- process = subprocess .Popen ([
627
- sys .executable ,
628
- "-m" ,
629
- "cwltool"
630
- ] + new_args , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
618
+ process = subprocess .Popen (
619
+ [sys .executable , "-m" , "cwltool" ] + new_args ,
620
+ stdout = subprocess .PIPE , stderr = subprocess .PIPE )
631
621
632
622
stdout , stderr = process .communicate ()
633
623
return process .returncode , stdout .decode (), stderr .decode ()
@@ -684,15 +674,15 @@ def test_issue_740_fixed(self):
684
674
class TestChecksum (TestCmdLine ):
685
675
686
676
def test_compute_checksum (self ):
687
- f = cwltool .factory .Factory (compute_checksum = True ,
688
- use_container = onWindows ())
677
+ runtime_context = RuntimeContext ()
678
+ runtime_context .compute_checksum = True
679
+ runtime_context .use_container = onWindows ()
680
+ f = cwltool .factory .Factory (runtime_context = runtime_context )
689
681
echo = f .make (get_data ("tests/wf/cat-tool.cwl" ))
690
- output = echo (file1 = {
691
- "class" : "File" ,
692
- "location" : get_data ("tests/wf/whale.txt" )
693
- },
694
- reverse = False
695
- )
682
+ output = echo (
683
+ file1 = {"class" : "File" ,
684
+ "location" : get_data ("tests/wf/whale.txt" )},
685
+ reverse = False )
696
686
self .assertEquals (output ['output' ]["checksum" ], "sha1$327fc7aedf4f6b69a42a7c8b808dc5a7aff61376" )
697
687
698
688
def test_no_compute_checksum (self ):
@@ -721,5 +711,6 @@ def test_singularity_workflow(self):
721
711
self .assertIn ("completed success" , stderr )
722
712
self .assertEquals (error_code , 0 )
723
713
714
+
724
715
if __name__ == '__main__' :
725
716
unittest .main ()
0 commit comments