Skip to content

Commit d8d3506

Browse files
authored
Don't display 'previous task failed' with verbose <= 1. (#285)
1 parent 3575ede commit d8d3506

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

docs/source/changes.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ chronological order. Releases follow [semantic versioning](https://semver.org/)
55
releases are available on [PyPI](https://pypi.org/project/pytask) and
66
[Anaconda.org](https://anaconda.org/conda-forge/pytask).
77

8-
## 0.2.3 - 2022-xx-xx
8+
## 0.2.4 - 2022-xx-xx
9+
10+
- {pull}`279` enhances some tutorials with spell and grammar checking.
11+
- {pull}`282` updates the tox configuration.
12+
- {pull}`283` fixes an issue with coverage and tests using pexpect + `pdb.set_trace()`.
13+
- {pull}`285` implements that pytask does not show the traceback of tasks which are
14+
skipped because its previous task failed. Fixes {issue}`284`.
15+
16+
## 0.2.3 - 2022-05-30
917

1018
- {pull}`276` fixes `pytask clean` when git is not installed. Fixes {issue}`275`.
1119
- {pull}`277` ignores `DeprecationWarning` and `PendingDeprecationWarning` by default.

src/_pytask/execute.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ def pytask_execute_log_end(session: Session, reports: list[ExecutionReport]) ->
250250
console.print()
251251

252252
for report in reports:
253-
if report.outcome in (TaskOutcome.FAIL, TaskOutcome.SKIP_PREVIOUS_FAILED):
253+
if report.outcome == TaskOutcome.FAIL or (
254+
report.outcome == TaskOutcome.SKIP_PREVIOUS_FAILED
255+
and session.config["verbose"] >= 2
256+
):
254257
_print_errored_task_report(session, report)
255258

256259
console.rule(style="dim")

tests/test_execute.py

+22
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,25 @@ def task_error(): raise ValueError
308308
assert len(matches_traceback) == 2
309309
else:
310310
assert len(matches_traceback) == 1
311+
312+
313+
@pytest.mark.end_to_end
314+
@pytest.mark.parametrize("verbose", [1, 2])
315+
def test_traceback_of_previous_task_failed_is_not_shown(runner, tmp_path, verbose):
316+
source = """
317+
import pytask
318+
319+
@pytask.mark.produces("in.txt")
320+
def task_first(): raise ValueError
321+
322+
@pytask.mark.depends_on("in.txt")
323+
def task_second(): pass
324+
"""
325+
tmp_path.joinpath("task_example.py").write_text(textwrap.dedent(source))
326+
327+
result = runner.invoke(cli, [tmp_path.as_posix(), "--verbose", str(verbose)])
328+
329+
assert result.exit_code == ExitCode.FAILED
330+
assert ("Task task_example.py::task_second failed" in result.output) is (
331+
verbose == 2
332+
)

0 commit comments

Comments
 (0)