Skip to content

Commit cb2f021

Browse files
authored
Add test for pytask-dev/pytask#216. (#36)
1 parent a96ba51 commit cb2f021

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ chronological order. Releases follow `semantic versioning <https://semver.org/>`
66
all releases are available on `PyPI <https://pypi.org/project/pytask-parallel>`_ and
77
`Anaconda.org <https://anaconda.org/conda-forge/pytask-parallel>`_.
88

9+
0.1.2 - 2022-xx-xx
10+
------------------
11+
12+
- :gh:`36` adds a test for https://github.com/pytask-dev/pytask/issues/216.
13+
914

1015
0.1.1 - 2022-02-08
1116
------------------

src/pytask_parallel/execute.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def _unserialize_and_execute_task(bytes_, show_locals, console_options):
179179
def _process_exception(
180180
exc_info: tuple[Any], show_locals: bool, console_options: ConsoleOptions
181181
) -> tuple[Any]:
182+
"""Process the exception and convert the traceback to a string."""
182183
exc_info = remove_internal_traceback_frames_from_exc_info(exc_info)
183184
traceback = Traceback.from_exception(*exc_info, show_locals=show_locals)
184185
segments = console.render(traceback, options=console_options)

tests/test_execute.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,29 @@ def task_raising_error():
267267
assert "───── Traceback" in result.output
268268
assert ("───── locals" in result.output) is show_locals
269269
assert ("[0, 1, 2, 3, 4]" in result.output) is show_locals
270+
271+
272+
@pytest.mark.end_to_end
273+
@pytest.mark.parametrize("parallel_backend", PARALLEL_BACKENDS)
274+
def test_generators_are_removed_from_depends_on_produces(tmp_path, parallel_backend):
275+
"""Only works with pytask >=0.1.9."""
276+
source = """
277+
from pathlib import Path
278+
import pytask
279+
280+
@pytask.mark.parametrize("produces", [
281+
((x for x in ["out.txt", "out_2.txt"]),),
282+
["in.txt"],
283+
])
284+
def task_example(produces):
285+
produces = {0: produces} if isinstance(produces, Path) else produces
286+
for p in produces.values():
287+
p.write_text("hihi")
288+
"""
289+
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
290+
291+
session = main(
292+
{"paths": tmp_path, "parallel_backend": parallel_backend, "n_workers": 2}
293+
)
294+
295+
assert session.exit_code == 0

0 commit comments

Comments
 (0)