Skip to content

Commit

Permalink
MNT: stop warnings during tests from using deprecated .command property
Browse files Browse the repository at this point in the history
Switch outdated tests to use .commands, which is not deprecated.
And supress the error for when intentionally using deprecated call.
  • Loading branch information
nstelter-slac committed Dec 20, 2024
1 parent 3fde371 commit 7ab612e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pydm/tests/widgets/test_shell_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ def test_construct(qtbot, command, title):
assert test_icon_image == shell_cmd_icon_image


@pytest.mark.filterwarnings("ignore:'PyDMShellCommand.command' is deprecated")
def test_deprecated_command_property_with_no_commands(qtbot):
pydm_shell_command = PyDMShellCommand()
qtbot.addWidget(pydm_shell_command)
pydm_shell_command.command = "test"
assert pydm_shell_command.commands == ["test"]


@pytest.mark.filterwarnings("ignore:'PyDMShellCommand.command' is deprecated")
def test_deprecated_command_property_with_commands(qtbot):
pydm_shell_command = PyDMShellCommand()
qtbot.addWidget(pydm_shell_command)
Expand All @@ -122,15 +124,15 @@ def test_no_crash_without_any_commands(qtbot):
def test_no_crash_with_none_command(qtbot):
pydm_shell_command = PyDMShellCommand()
qtbot.addWidget(pydm_shell_command)
pydm_shell_command.command = None
pydm_shell_command.commands = None
qtbot.mouseClick(pydm_shell_command, QtCore.Qt.LeftButton)


def test_no_error_without_env_variable(qtbot, caplog):
"""Verify that the shell command works when the environment variable property is saved as an empty string"""
pydm_shell_command = PyDMShellCommand()
qtbot.addWidget(pydm_shell_command)
pydm_shell_command.command = "echo hello"
pydm_shell_command.commands = ["echo hello"]
pydm_shell_command.environmentVariables = ""
qtbot.mouseClick(pydm_shell_command, QtCore.Qt.LeftButton)
assert "error" not in caplog.text.lower()
Expand Down

0 comments on commit 7ab612e

Please sign in to comment.