7
7
8
8
import pytest
9
9
from pytask import cli
10
+ from pytask import ExitCode
10
11
from pytask import main
11
12
from pytask import Task
12
13
from pytask_parallel .backends import PARALLEL_BACKENDS
@@ -39,7 +40,7 @@ def task_2(produces):
39
40
40
41
session = main ({"paths" : tmp_path })
41
42
42
- assert session .exit_code == 0
43
+ assert session .exit_code == ExitCode . OK
43
44
assert session .execution_end - session .execution_start > 10
44
45
45
46
tmp_path .joinpath ("out_1.txt" ).unlink ()
@@ -49,7 +50,7 @@ def task_2(produces):
49
50
{"paths" : tmp_path , "n_workers" : 2 , "parallel_backend" : parallel_backend }
50
51
)
51
52
52
- assert session .exit_code == 0
53
+ assert session .exit_code == ExitCode . OK
53
54
assert session .execution_end - session .execution_start < 10
54
55
55
56
@@ -76,7 +77,7 @@ def task_2(produces):
76
77
result = runner .invoke (cli , [tmp_path .as_posix ()])
77
78
end = time ()
78
79
79
- assert result .exit_code == 0
80
+ assert result .exit_code == ExitCode . OK
80
81
assert end - start > 10
81
82
82
83
tmp_path .joinpath ("out_1.txt" ).unlink ()
@@ -95,7 +96,7 @@ def task_2(produces):
95
96
)
96
97
end = time ()
97
98
98
- assert result .exit_code == 0
99
+ assert result .exit_code == ExitCode . OK
99
100
assert "Started 2 workers." in result .output
100
101
assert end - start < 10
101
102
@@ -162,6 +163,7 @@ def task_2(produces):
162
163
}
163
164
)
164
165
166
+ assert session .exit_code == ExitCode .OK
165
167
assert 3 < session .execution_end - session .execution_start < 10
166
168
167
169
@@ -190,6 +192,7 @@ def task_3():
190
192
}
191
193
)
192
194
195
+ assert session .exit_code == ExitCode .OK
193
196
assert len (session .tasks ) == 3
194
197
assert len (session .execution_reports ) == 2
195
198
@@ -229,7 +232,7 @@ def task_5():
229
232
{"paths" : tmp_path , "parallel_backend" : parallel_backend , "n_workers" : 2 }
230
233
)
231
234
232
- assert session .exit_code == 0
235
+ assert session .exit_code == ExitCode . OK
233
236
first_task_name = session .execution_reports [0 ].task .name
234
237
assert first_task_name .endswith ("task_0" ) or first_task_name .endswith ("task_3" )
235
238
last_task_name = session .execution_reports [- 1 ].task .name
@@ -256,7 +259,7 @@ def task_raising_error():
256
259
args .append ("--show-locals" )
257
260
result = runner .invoke (cli , args )
258
261
259
- assert result .exit_code == 1
262
+ assert result .exit_code == ExitCode . FAILED
260
263
assert "───── Traceback" in result .output
261
264
assert ("───── locals" in result .output ) is show_locals
262
265
assert ("[0, 1, 2, 3, 4]" in result .output ) is show_locals
@@ -285,4 +288,4 @@ def task_example(produces):
285
288
{"paths" : tmp_path , "parallel_backend" : parallel_backend , "n_workers" : 2 }
286
289
)
287
290
288
- assert session .exit_code == 0
291
+ assert session .exit_code == ExitCode . OK
0 commit comments