mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add additional deprecation warning tests
This commit is contained in:
parent
4d9eee7753
commit
7121882744
1 changed files with 20 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue