@@ -20,68 +20,41 @@ class Session:
20
20
21
21
@pytest .mark .end_to_end ()
22
22
@pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
23
- def test_parallel_execution_speedup (tmp_path , parallel_backend ):
23
+ def test_parallel_execution (tmp_path , parallel_backend ):
24
24
source = """
25
25
import pytask
26
- import time
27
26
28
27
@pytask.mark.produces("out_1.txt")
29
28
def task_1(produces):
30
- time.sleep(5)
31
29
produces.write_text("1")
32
30
33
31
@pytask.mark.produces("out_2.txt")
34
32
def task_2(produces):
35
- time.sleep(5)
36
33
produces.write_text("2")
37
34
"""
38
35
tmp_path .joinpath ("task_example.py" ).write_text (textwrap .dedent (source ))
39
-
40
- with restore_sys_path_and_module_after_test_execution ():
41
- session = build (paths = tmp_path )
42
-
43
- assert session .exit_code == ExitCode .OK
44
- assert session .execution_end - session .execution_start > 10
45
-
46
- tmp_path .joinpath ("out_1.txt" ).unlink ()
47
- tmp_path .joinpath ("out_2.txt" ).unlink ()
48
-
49
36
session = build (paths = tmp_path , n_workers = 2 , parallel_backend = parallel_backend )
50
-
51
37
assert session .exit_code == ExitCode .OK
52
- assert session .execution_end - session .execution_start < 10
38
+ assert len (session .tasks ) == 2
39
+ assert tmp_path .joinpath ("out_1.txt" ).exists ()
40
+ assert tmp_path .joinpath ("out_2.txt" ).exists ()
53
41
54
42
55
43
@pytest .mark .end_to_end ()
56
44
@pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
57
- def test_parallel_execution_speedup_w_cli (runner , tmp_path , parallel_backend ):
45
+ def test_parallel_execution_w_cli (runner , tmp_path , parallel_backend ):
58
46
source = """
59
47
import pytask
60
- import time
61
48
62
49
@pytask.mark.produces("out_1.txt")
63
50
def task_1(produces):
64
- time.sleep(5)
65
51
produces.write_text("1")
66
52
67
53
@pytask.mark.produces("out_2.txt")
68
54
def task_2(produces):
69
- time.sleep(5)
70
55
produces.write_text("2")
71
56
"""
72
57
tmp_path .joinpath ("task_example.py" ).write_text (textwrap .dedent (source ))
73
-
74
- start = time ()
75
- result = runner .invoke (cli , [tmp_path .as_posix ()])
76
- end = time ()
77
-
78
- assert result .exit_code == ExitCode .OK
79
- assert end - start > 10
80
-
81
- tmp_path .joinpath ("out_1.txt" ).unlink ()
82
- tmp_path .joinpath ("out_2.txt" ).unlink ()
83
-
84
- start = time ()
85
58
result = runner .invoke (
86
59
cli ,
87
60
[
@@ -92,11 +65,9 @@ def task_2(produces):
92
65
parallel_backend ,
93
66
],
94
67
)
95
- end = time ()
96
-
97
68
assert result .exit_code == ExitCode .OK
98
- assert "Started 2 workers." in result . output
99
- assert end - start < 10
69
+ assert tmp_path . joinpath ( "out_1.txt" ). exists ()
70
+ assert tmp_path . joinpath ( "out_2.txt" ). exists ()
100
71
101
72
102
73
@pytest .mark .end_to_end ()
0 commit comments