1
1
from __future__ import annotations
2
2
3
3
import os
4
+ import subprocess
4
5
import sys
5
6
import textwrap
6
7
@@ -65,7 +66,7 @@ def task_example(path=Path("input.txt")): ...
65
66
@pytest .mark .parametrize ("layout" , _GRAPH_LAYOUTS )
66
67
@pytest .mark .parametrize ("format_" , _TEST_FORMATS )
67
68
@pytest .mark .parametrize ("rankdir" , [_RankDirection .LR .value , _RankDirection .TB ])
68
- def test_create_graph_via_task (tmp_path , runner , format_ , layout , rankdir ):
69
+ def test_create_graph_via_task (tmp_path , format_ , layout , rankdir ):
69
70
if sys .platform == "win32" and format_ == "pdf" : # pragma: no cover
70
71
pytest .xfail ("gvplugin_pango.dll might be missing on Github Actions." )
71
72
@@ -78,20 +79,24 @@ def test_create_graph_via_task(tmp_path, runner, format_, layout, rankdir):
78
79
79
80
def task_example(path=Path("input.txt")): ...
80
81
81
- def task_create_graph ():
82
+ def main ():
82
83
dag = pytask.build_dag({{"paths": Path(__file__).parent}})
83
84
dag.graph = {{"rankdir": "{ rankdir_str } "}}
84
85
graph = nx.nx_agraph.to_agraph(dag)
85
86
path = Path(__file__).parent.joinpath("dag.{ format_ } ")
86
87
graph.draw(path, prog="{ layout } ")
87
- """
88
88
89
+ if __name__ == "__main__":
90
+ main()
91
+ """
89
92
tmp_path .joinpath ("task_example.py" ).write_text (textwrap .dedent (source ))
90
93
tmp_path .joinpath ("input.txt" ).touch ()
91
94
92
- result = runner .invoke (cli , [tmp_path .as_posix ()])
95
+ result = subprocess .run (
96
+ ("python" , "task_example.py" ), cwd = tmp_path , check = True , capture_output = True
97
+ )
93
98
94
- assert result .exit_code == ExitCode .OK
99
+ assert result .returncode == ExitCode .OK
95
100
assert tmp_path .joinpath (f"dag.{ format_ } " ).exists ()
96
101
97
102
0 commit comments