Skip to content

Commit 1afb086

Browse files
committed
Implement test which checks that DeprecationWarning and PendingDeprecationWarning are ignored.
1 parent e60c8a0 commit 1afb086

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/source/changes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
88
## 0.2.3 - 2022-xx-xx
99

1010
- {pull}`276` fixes `pytask clean` when git is not installed. Fixes {issue}`275`.
11+
- {pull}`277` ignores `DeprecationWarning` and `PendingDeprecationWarning` by default.
12+
Previously, they were enabled, but they should be shown when testing the project with
13+
pytest, not after the execution with pytask.
1114

1215
## 0.2.2 - 2022-05-14
1316

tests/test_warnings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,19 @@ def task_example():
119119
assert result.exit_code == ExitCode.OK
120120
assert ("Warnings" in result.output) is not add_config
121121
assert ("warning!!!" in result.output) is not add_config
122+
123+
124+
@pytest.mark.parametrize("warning", ["DeprecationWarning", "PendingDeprecationWarning"])
125+
def test_deprecation_warnings_are_not_captured(tmp_path, runner, warning):
126+
source = f"""
127+
import warnings
128+
129+
def task_example():
130+
warnings.warn("warning!!!", {warning})
131+
"""
132+
tmp_path.joinpath("task_example.py").write_text(textwrap.dedent(source))
133+
result = runner.invoke(cli, [tmp_path.as_posix()])
134+
135+
assert result.exit_code == ExitCode.OK
136+
assert "Warnings" not in result.output
137+
assert "warning!!!" not in result.output

0 commit comments

Comments
 (0)