Skip to content

Commit 149778a

Browse files
committed
Remove flaky tests.
1 parent 4e95d0c commit 149778a

File tree

1 file changed

+7
-36
lines changed

1 file changed

+7
-36
lines changed

tests/test_execute.py

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,68 +20,41 @@ class Session:
2020

2121
@pytest.mark.end_to_end()
2222
@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):
2424
source = """
2525
import pytask
26-
import time
2726
2827
@pytask.mark.produces("out_1.txt")
2928
def task_1(produces):
30-
time.sleep(5)
3129
produces.write_text("1")
3230
3331
@pytask.mark.produces("out_2.txt")
3432
def task_2(produces):
35-
time.sleep(5)
3633
produces.write_text("2")
3734
"""
3835
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-
4936
session = build(paths=tmp_path, n_workers=2, parallel_backend=parallel_backend)
50-
5137
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()
5341

5442

5543
@pytest.mark.end_to_end()
5644
@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):
5846
source = """
5947
import pytask
60-
import time
6148
6249
@pytask.mark.produces("out_1.txt")
6350
def task_1(produces):
64-
time.sleep(5)
6551
produces.write_text("1")
6652
6753
@pytask.mark.produces("out_2.txt")
6854
def task_2(produces):
69-
time.sleep(5)
7055
produces.write_text("2")
7156
"""
7257
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()
8558
result = runner.invoke(
8659
cli,
8760
[
@@ -92,11 +65,9 @@ def task_2(produces):
9265
parallel_backend,
9366
],
9467
)
95-
end = time()
96-
9768
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()
10071

10172

10273
@pytest.mark.end_to_end()

0 commit comments

Comments
 (0)