8
8
from _pytask .collect_command import _find_common_ancestor_of_all_nodes
9
9
from _pytask .collect_command import _print_collected_tasks
10
10
from pytask import cli
11
+ from pytask import ExitCode
11
12
from pytask import MetaNode
12
13
from pytask import Task
13
14
@@ -27,6 +28,7 @@ def task_example():
27
28
28
29
result = runner .invoke (cli , ["collect" , tmp_path .as_posix ()])
29
30
31
+ assert result .exit_code == ExitCode .OK
30
32
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
31
33
assert "<Module" in captured
32
34
assert "task_module.py>" in captured
@@ -35,6 +37,7 @@ def task_example():
35
37
36
38
result = runner .invoke (cli , ["collect" , tmp_path .as_posix (), "--nodes" ])
37
39
40
+ assert result .exit_code == ExitCode .OK
38
41
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
39
42
assert "<Module" in captured
40
43
assert "task_module.py>" in captured
@@ -61,6 +64,7 @@ def task_example(arg):
61
64
62
65
result = runner .invoke (cli , ["collect" , tmp_path .as_posix ()])
63
66
67
+ assert result .exit_code == ExitCode .OK
64
68
captured = result .output .replace ("\n " , "" ).replace (" " , "" ).replace ("\u2502 " , "" )
65
69
assert "<Module" in captured
66
70
assert "task_module.py>" in captured
@@ -90,6 +94,7 @@ def task_example_2():
90
94
91
95
result = runner .invoke (cli , ["collect" , tmp_path .as_posix (), "-k" , "_1" ])
92
96
97
+ assert result .exit_code == ExitCode .OK
93
98
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
94
99
assert "<Module" in captured
95
100
assert "task_module.py>" in captured
@@ -100,6 +105,7 @@ def task_example_2():
100
105
101
106
result = runner .invoke (cli , ["collect" , tmp_path .as_posix (), "-k" , "_1" , "--nodes" ])
102
107
108
+ assert result .exit_code == ExitCode .OK
103
109
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
104
110
assert "<Module" in captured
105
111
assert "task_module.py>" in captured
@@ -140,6 +146,7 @@ def task_example_2():
140
146
141
147
result = runner .invoke (cli , ["collect" , tmp_path .as_posix (), "-m" , "wip" ])
142
148
149
+ assert result .exit_code == ExitCode .OK
143
150
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
144
151
assert "<Module" in captured
145
152
assert "task_module.py>" in captured
@@ -152,6 +159,7 @@ def task_example_2():
152
159
cli , ["collect" , tmp_path .as_posix (), "-m" , "wip" , "--nodes" ]
153
160
)
154
161
162
+ assert result .exit_code == ExitCode .OK
155
163
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
156
164
assert "<Module" in captured
157
165
assert "task_module.py>" in captured
@@ -190,6 +198,7 @@ def task_example_2():
190
198
191
199
result = runner .invoke (cli , ["collect" , tmp_path .as_posix (), "-m" , "wip" ])
192
200
201
+ assert result .exit_code == ExitCode .OK
193
202
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
194
203
assert "<Module" in captured
195
204
assert "task_module.py>" in captured
@@ -202,6 +211,7 @@ def task_example_2():
202
211
cli , ["collect" , tmp_path .as_posix (), "-m" , "wip" , "--nodes" ]
203
212
)
204
213
214
+ assert result .exit_code == ExitCode .OK
205
215
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
206
216
assert "<Module" in captured
207
217
assert "task_module.py>" in captured
@@ -243,6 +253,7 @@ def task_example_2():
243
253
244
254
result = runner .invoke (cli , ["collect" , tmp_path .as_posix ()])
245
255
256
+ assert result .exit_code == ExitCode .OK
246
257
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
247
258
assert "<Module" in captured
248
259
assert "task_example_1.py>" in captured
@@ -254,6 +265,7 @@ def task_example_2():
254
265
255
266
result = runner .invoke (cli , ["collect" , tmp_path .as_posix (), "--nodes" ])
256
267
268
+ assert result .exit_code == ExitCode .OK
257
269
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
258
270
assert "<Module" in captured
259
271
assert "task_example_1.py>" in captured
@@ -295,6 +307,7 @@ def task_example_2():
295
307
296
308
result = runner .invoke (cli , ["collect" , tmp_path .as_posix ()])
297
309
310
+ assert result .exit_code == ExitCode .OK
298
311
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
299
312
assert "<Module" in captured
300
313
assert "task_example_1.py>" in captured
@@ -306,6 +319,7 @@ def task_example_2():
306
319
307
320
result = runner .invoke (cli , ["collect" , tmp_path .as_posix (), "--nodes" ])
308
321
322
+ assert result .exit_code == ExitCode .OK
309
323
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
310
324
assert "<Module" in captured
311
325
assert "task_example_1.py>" in captured
@@ -343,6 +357,7 @@ def task_example_2():
343
357
cli , ["collect" , tmp_path .as_posix (), "--ignore" , "task_example_2.py" ]
344
358
)
345
359
360
+ assert result .exit_code == ExitCode .OK
346
361
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
347
362
assert "<Module" in captured
348
363
assert "task_example_1.py>" in captured
@@ -357,6 +372,7 @@ def task_example_2():
357
372
["collect" , tmp_path .as_posix (), "--ignore" , "task_example_2.py" , "--nodes" ],
358
373
)
359
374
375
+ assert result .exit_code == ExitCode .OK
360
376
captured = result .output .replace ("\n " , "" ).replace (" " , "" )
361
377
assert "<Module" in captured
362
378
assert "task_example_1.py>" in captured
@@ -398,7 +414,6 @@ def test_print_collected_tasks_without_nodes(capsys):
398
414
_print_collected_tasks (dictionary , False , "file" , Path ())
399
415
400
416
captured = capsys .readouterr ().out
401
-
402
417
assert "<Module task_path.py>" in captured
403
418
assert "<Function task_path.py::function>" in captured
404
419
assert "<Dependency in.txt>" not in captured
@@ -444,3 +459,15 @@ def test_find_common_ancestor_of_all_nodes(show_nodes, expected_add):
444
459
445
460
result = _find_common_ancestor_of_all_nodes (tasks , [Path .cwd () / "src" ], show_nodes )
446
461
assert result == Path .cwd ().joinpath (expected_add ).resolve ()
462
+
463
+
464
+ @pytest .mark .end_to_end
465
+ def test_task_name_is_shortened (runner , tmp_path ):
466
+ tmp_path .joinpath ("a" , "b" ).mkdir (parents = True )
467
+ tmp_path .joinpath ("a" , "b" , "task_example.py" ).write_text ("def task_example(): ..." )
468
+
469
+ result = runner .invoke (cli , ["collect" , tmp_path .as_posix ()])
470
+
471
+ assert result .exit_code == ExitCode .OK
472
+ assert "task_example.py::task_example" in result .output
473
+ assert "a/b/task_example.py::task_example" not in result .output
0 commit comments