11import os
22import textwrap
3- from contextlib import contextmanager
3+ from contextlib import ExitStack as does_not_raise # noqa: N813
44
55import pytest
66from pytask .main import main
77from pytask .mark import Mark
88from pytask .outcomes import Skipped
99from pytask .outcomes import SkippedAncestorFailed
1010from pytask .outcomes import SkippedUnchanged
11+ from pytask .report import ExecutionReport
1112from pytask .skipping import pytask_execute_task_log_end
1213from pytask .skipping import pytask_execute_task_setup
1314
1415
15- @contextmanager
16- def does_not_raise ():
17- yield
18-
19-
2016@pytest .mark .end_to_end
2117def test_skip_unchanged (tmp_path ):
2218 source = """
@@ -26,10 +22,10 @@ def task_dummy():
2622 tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (source ))
2723
2824 session = main ({"paths" : tmp_path })
29- assert session .results [0 ][ " success" ]
25+ assert session .execution_reports [0 ]. success
3026
3127 session = main ({"paths" : tmp_path })
32- assert isinstance (session .results [0 ][ "value" ], SkippedUnchanged )
28+ assert isinstance (session .execution_reports [0 ]. exc_info [ 1 ], SkippedUnchanged )
3329
3430
3531@pytest .mark .end_to_end
@@ -51,12 +47,12 @@ def task_dummy():
5147 os .chdir (tmp_path )
5248 session = main ({"paths" : tmp_path })
5349
54- assert session .results [0 ][ " success" ]
50+ assert session .execution_reports [0 ]. success
5551 assert tmp_path .joinpath ("out.txt" ).read_text () == "Original content of in.txt."
5652
5753 session = main ({"paths" : tmp_path })
5854
59- assert isinstance (session .results [0 ][ "value" ], SkippedUnchanged )
55+ assert isinstance (session .execution_reports [0 ]. exc_info [ 1 ], SkippedUnchanged )
6056 assert tmp_path .joinpath ("out.txt" ).read_text () == "Original content of in.txt."
6157
6258
@@ -81,10 +77,10 @@ def task_second():
8177 os .chdir (tmp_path )
8278 session = main ({"paths" : tmp_path })
8379
84- assert not session .results [0 ][ " success" ]
85- assert isinstance (session .results [0 ][ "value" ], Exception )
86- assert not session .results [1 ][ " success" ]
87- assert isinstance (session .results [1 ][ "value" ], SkippedAncestorFailed )
80+ assert not session .execution_reports [0 ]. success
81+ assert isinstance (session .execution_reports [0 ]. exc_info [ 1 ], Exception )
82+ assert not session .execution_reports [1 ]. success
83+ assert isinstance (session .execution_reports [1 ]. exc_info [ 1 ], SkippedAncestorFailed )
8884
8985
9086def test_if_skip_decorator_is_applied (tmp_path ):
@@ -108,10 +104,10 @@ def task_second():
108104 os .chdir (tmp_path )
109105 session = main ({"paths" : tmp_path })
110106
111- assert session .results [0 ][ " success" ]
112- assert isinstance (session .results [0 ][ "value" ], Skipped )
113- assert session .results [1 ][ " success" ]
114- assert isinstance (session .results [1 ][ "value" ], Skipped )
107+ assert session .execution_reports [0 ]. success
108+ assert isinstance (session .execution_reports [0 ]. exc_info [ 1 ], Skipped )
109+ assert session .execution_reports [1 ]. success
110+ assert isinstance (session .execution_reports [1 ]. exc_info [ 1 ], Skipped )
115111
116112
117113@pytest .mark .unit
@@ -148,13 +144,15 @@ class Task:
148144)
149145def test_pytask_execute_task_log_end (capsys , exception , character ):
150146 if isinstance (exception , (Skipped , SkippedUnchanged )):
151- result = {"success" : False , "value" : exception ()}
147+ report = ExecutionReport .from_task_and_exception ((), exception ())
148+ report .success = True
152149 elif isinstance (exception , SkippedAncestorFailed ):
153- result = {"success" : True , "value" : SkippedAncestorFailed (), "reason" : "" }
150+ report = ExecutionReport .from_task_and_exception ((), SkippedAncestorFailed )
151+ report .success = True
154152 else :
155- result = { "success" : True , "value" : None }
153+ report = ExecutionReport . from_task (())
156154
157- out = pytask_execute_task_log_end (result )
155+ out = pytask_execute_task_log_end (report )
158156
159157 captured = capsys .readouterr ()
160158 if isinstance (exception , (Skipped , SkippedUnchanged )):
0 commit comments