Skip to content

Commit 4c55e91

Browse files
committed
Add test for a warning in the same location raised by parametrized tasks.
1 parent bec6d2e commit 4c55e91

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

docs/source/changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
1111
- {pull}`277` ignores `DeprecationWarning` and `PendingDeprecationWarning` by default.
1212
Previously, they were enabled, but they should be shown when testing the project with
1313
pytest, not after the execution with pytask. Fixes {issue}`269`.
14+
- {pull}`278` counts multiple occurrences of a warning instead of listing the module or
15+
task name again and again. Fixes {issue}`270`.
1416

1517
## 0.2.2 - 2022-05-14
1618

tests/test_warnings.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,24 @@ def warn_now():
155155
assert result.returncode == ExitCode.OK
156156
assert "Warnings" not in result.stdout.decode()
157157
assert "warning!!!" not in result.stdout.decode()
158+
159+
160+
def test_multiple_occurrences_of_warning(tmp_path, runner):
161+
source = """
162+
import warnings
163+
import pytask
164+
165+
for i in range(10):
166+
167+
@pytask.mark.task
168+
def task_example():
169+
warnings.warn("warning!!!")
170+
"""
171+
tmp_path.joinpath("task_example.py").write_text(textwrap.dedent(source))
172+
173+
result = runner.invoke(cli, [tmp_path.as_posix()])
174+
175+
assert result.exit_code == ExitCode.OK
176+
assert "Warnings" in result.output
177+
assert "warning!!!" in result.output
178+
assert result.output.count("task_example") == 41

0 commit comments

Comments
 (0)