mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Use pytest skips
This commit is contained in:
parent
1e3e69609c
commit
2175f8f0e2
3 changed files with 14 additions and 14 deletions
|
@ -10,7 +10,6 @@ import salt.utils.user
|
|||
from tests.support.case import ModuleCase
|
||||
from tests.support.helpers import dedent
|
||||
from tests.support.runtests import RUNTIME_VARS
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
AVAILABLE_PYTHON_EXECUTABLE = salt.utils.path.which_bin(
|
||||
["python", "python2", "python2.6", "python2.7"]
|
||||
|
@ -351,7 +350,7 @@ class CMDModuleTest(ModuleCase):
|
|||
self.assertEqual(result, expected_result)
|
||||
|
||||
@pytest.mark.skip_if_not_root
|
||||
@skipIf(salt.utils.platform.is_windows(), "skip windows, requires password")
|
||||
@pytest.mark.skip_on_windows(reason="Skip on Windows, requires password")
|
||||
def test_quotes_runas(self):
|
||||
"""
|
||||
cmd.run with quoted command
|
||||
|
@ -367,7 +366,7 @@ class CMDModuleTest(ModuleCase):
|
|||
|
||||
@pytest.mark.destructive_test
|
||||
@pytest.mark.skip_if_not_root
|
||||
@skipIf(salt.utils.platform.is_windows(), "skip windows, uses unix commands")
|
||||
@pytest.mark.skip_on_windows(reason="Skip on Windows, uses unix commands")
|
||||
@pytest.mark.slow_test
|
||||
def test_avoid_injecting_shell_code_as_root(self):
|
||||
"""
|
||||
|
@ -389,7 +388,7 @@ class CMDModuleTest(ModuleCase):
|
|||
|
||||
@pytest.mark.destructive_test
|
||||
@pytest.mark.skip_if_not_root
|
||||
@skipIf(salt.utils.platform.is_windows(), "skip windows, uses unix commands")
|
||||
@pytest.mark.skip_on_windows(reason="Skip on Windows, uses unix commands")
|
||||
@pytest.mark.slow_test
|
||||
def test_cwd_runas(self):
|
||||
"""
|
||||
|
@ -413,7 +412,7 @@ class CMDModuleTest(ModuleCase):
|
|||
|
||||
@pytest.mark.destructive_test
|
||||
@pytest.mark.skip_if_not_root
|
||||
@skipIf(not salt.utils.platform.is_darwin(), "applicable to MacOS only")
|
||||
@pytest.mark.skip_unless_on_darwin(reason="Applicable to MacOS only")
|
||||
@pytest.mark.slow_test
|
||||
def test_runas_env(self):
|
||||
"""
|
||||
|
@ -431,7 +430,7 @@ class CMDModuleTest(ModuleCase):
|
|||
|
||||
@pytest.mark.destructive_test
|
||||
@pytest.mark.skip_if_not_root
|
||||
@skipIf(not salt.utils.platform.is_darwin(), "applicable to MacOS only")
|
||||
@pytest.mark.skip_unless_on_darwin(reason="Applicable to MacOS only")
|
||||
@pytest.mark.slow_test
|
||||
def test_runas_complex_command_bad_cwd(self):
|
||||
"""
|
||||
|
@ -459,7 +458,7 @@ class CMDModuleTest(ModuleCase):
|
|||
self.assertNotIn("You have failed the test", cmd_result["stderr"])
|
||||
self.assertNotEqual(0, cmd_result["retcode"])
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), "minion is windows")
|
||||
@pytest.mark.skip_on_windows(reason="Minion is Windows")
|
||||
@pytest.mark.skip_if_not_root
|
||||
@pytest.mark.destructive_test
|
||||
@pytest.mark.slow_test
|
||||
|
@ -473,7 +472,7 @@ class CMDModuleTest(ModuleCase):
|
|||
).splitlines()
|
||||
self.assertIn("USER={}".format(self.runas_usr), out)
|
||||
|
||||
@skipIf(not salt.utils.path.which_bin("sleep"), "sleep cmd not installed")
|
||||
@pytest.mark.skip_if_binaries_missing("sleep")
|
||||
def test_timeout(self):
|
||||
"""
|
||||
cmd.run trigger timeout
|
||||
|
@ -483,7 +482,7 @@ class CMDModuleTest(ModuleCase):
|
|||
)
|
||||
self.assertTrue("Timed out" in out)
|
||||
|
||||
@skipIf(not salt.utils.path.which_bin("sleep"), "sleep cmd not installed")
|
||||
@pytest.mark.skip_if_binaries_missing("sleep")
|
||||
def test_timeout_success(self):
|
||||
"""
|
||||
cmd.run sufficient timeout to succeed
|
||||
|
@ -544,7 +543,7 @@ class CMDModuleTest(ModuleCase):
|
|||
cmd = self.run_function("cmd.run", ["whoami"])
|
||||
self.assertEqual(user.lower(), cmd.lower())
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "minion is not windows")
|
||||
@pytest.mark.skip_unless_on_windows(reason="Minion is not Windows")
|
||||
@pytest.mark.slow_test
|
||||
def test_windows_env_handling(self):
|
||||
"""
|
||||
|
@ -557,7 +556,7 @@ class CMDModuleTest(ModuleCase):
|
|||
self.assertIn("ABC=456", out)
|
||||
|
||||
@pytest.mark.slow_test
|
||||
@skipIf(not salt.utils.platform.is_windows(), "minion is not windows")
|
||||
@pytest.mark.skip_unless_on_windows(reason="Minion is not Windows")
|
||||
def test_windows_powershell_script_args(self):
|
||||
"""
|
||||
Ensure that powershell processes inline script in args
|
||||
|
@ -571,11 +570,12 @@ class CMDModuleTest(ModuleCase):
|
|||
self.assertEqual(ret["stdout"], val)
|
||||
|
||||
@pytest.mark.slow_test
|
||||
@skipIf(not salt.utils.platform.is_windows(), "minion is not windows")
|
||||
@skipIf(not salt.utils.path.which("pwsh"), "Requires Powershell 7")
|
||||
@pytest.mark.skip_unless_on_windows(reason="Minion is not Windows")
|
||||
@pytest.mark.skip_if_binaries_missing("pwsh")
|
||||
def test_windows_powershell_script_args_pwsh(self):
|
||||
"""
|
||||
Ensure that powershell processes inline script in args with powershell 7
|
||||
Ensure that powershell processes inline script in args with powershell
|
||||
core
|
||||
"""
|
||||
val = "i like cheese"
|
||||
args = '-SecureString (ConvertTo-SecureString -String "{}" -AsPlainText -Force) -ErrorAction Stop'.format(
|
||||
|
|
0
tests/pytests/functional/modules/cmd/__init__.py
Normal file
0
tests/pytests/functional/modules/cmd/__init__.py
Normal file
Loading…
Add table
Reference in a new issue