Add additional deprecation warning tests

This commit is contained in:
Megan Wilhite 2023-08-25 21:15:44 -06:00 committed by Pedro Algarvio
parent 4d9eee7753
commit 7121882744

View file

@ -1,9 +1,24 @@
def test_deprecation_warnings_ignore(salt_call_cli):
import pytest
@pytest.mark.parametrize(
"env,warn_expected",
[
({"PYTHONWARNINGS": "ignore"}, False),
({"PYTHONWARNINGS": "test"}, True),
({}, True),
],
)
def test_deprecation_warnings(salt_call_cli, env, warn_expected):
"""
Test to ensure when env variable PYTHONWARNINGS=ignore
is set that we do not add warning to output.
And when it's not set to ignore the warning will show.
"""
ret = salt_call_cli.run(
"--local", "test.deprecation_warning", env={"PYTHONWARNINGS": "ignore"}
)
assert "DeprecationWarning" not in ret.stderr
ret = salt_call_cli.run("--local", "test.deprecation_warning", env=env)
if warn_expected:
assert "DeprecationWarning" in ret.stderr
assert ret.stderr.count("DeprecationWarning") >= 2
else:
assert "DeprecationWarning" not in ret.stderr
assert ret.data