Don't use run_function just to get grains to skip tests. Skip markers.

This commit is contained in:
Pedro Algarvio 2020-04-15 11:30:03 +01:00 committed by Daniel Wozniak
parent d916ce0b0b
commit b6c78ecba6
21 changed files with 141 additions and 241 deletions

View file

@ -9,7 +9,12 @@ import salt.utils.stringutils
from salt.ext import six
from salt.ext.six.moves import range
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, random_string, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
random_string,
runs_on,
skip_if_not_root,
)
from tests.support.unit import skipIf
if not salt.utils.platform.is_windows():
@ -19,6 +24,7 @@ if not salt.utils.platform.is_windows():
@skip_if_not_root
@destructiveTest
@pytest.mark.windows_whitelisted
@runs_on(kernel=("Linux", "Windows"))
class GroupModuleTest(ModuleCase):
"""
Validate the linux group system module
@ -34,13 +40,12 @@ class GroupModuleTest(ModuleCase):
self._no_user = random_string("tg-", uppercase=False)
self._group = random_string("tg-", uppercase=False)
self._no_group = random_string("tg-", uppercase=False)
self.os_grain = self.run_function("grains.item", ["kernel"])
self._gid = 64989 if "Windows" not in self.os_grain["kernel"] else None
self._new_gid = 64998 if "Windows" not in self.os_grain["kernel"] else None
if self.os_grain["kernel"] not in ("Linux", "Windows"):
self.skipTest(
"Test not applicable to '{kernel}' kernel".format(**self.os_grain)
)
_gid = _new_gid = None
if not salt.utils.platform.is_windows():
_gid = 64989
_new_gid = 64998
self._gid = _gid
self._new_gid = _new_gid
def tearDown(self):
"""

View file

@ -3,12 +3,10 @@
:codeauthor: Nicole Thomas <nicole@saltstack.com>
"""
# Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt Testing Libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
from tests.support.helpers import destructiveTest, runs_on, skip_if_not_root
from tests.support.unit import skipIf
OSA_SCRIPT = "/usr/bin/osascript"
@ -16,6 +14,7 @@ OSA_SCRIPT = "/usr/bin/osascript"
@destructiveTest
@skip_if_not_root
@runs_on(kernel="Darwin")
class MacAssistiveTest(ModuleCase):
"""
Integration tests for the mac_assistive module.
@ -25,10 +24,6 @@ class MacAssistiveTest(ModuleCase):
"""
Sets up test requirements
"""
os_grain = self.run_function("grains.item", ["kernel"])
if os_grain["kernel"] not in "Darwin":
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
# Let's install a bundle to use in tests
self.run_function("assistive.install", [OSA_SCRIPT, True])

View file

@ -3,20 +3,17 @@
:codeauthor: Nicole Thomas <nicole@saltstack.com>
"""
# Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt Libs
import salt.utils.path
import salt.utils.platform
from salt.exceptions import CommandExecutionError
# Import 3rd-party libs
from salt.ext import six
# Import Salt Testing Libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
runs_on,
skip_if_binaries_missing,
skip_if_not_root,
)
from tests.support.unit import skipIf
# Brew doesn't support local package installation - So, let's
@ -27,8 +24,8 @@ DEL_PKG = "acme"
@destructiveTest
@skip_if_not_root
@skipIf(not salt.utils.platform.is_darwin(), "Test only applies to macOS")
@skipIf(not salt.utils.path.which("brew"), "This test requires the brew binary")
@skip_if_binaries_missing("brew")
@runs_on(kernel="Darwin")
class BrewModuleTest(ModuleCase):
"""
Integration tests for the brew module

View file

@ -3,33 +3,22 @@
Integration tests for the mac_desktop execution module.
"""
# Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals
# Import 3rd-party libs
from salt.ext import six
# Import Salt Testing Libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
from tests.support.helpers import destructiveTest, runs_on, skip_if_not_root
from tests.support.unit import skipIf
@destructiveTest
@skip_if_not_root
@runs_on(kernel="Darwin")
class MacDesktopTestCase(ModuleCase):
"""
Integration tests for the mac_desktop module.
"""
def setUp(self):
"""
Sets up test requirements.
"""
os_grain = self.run_function("grains.item", ["kernel"])
if os_grain["kernel"] not in "Darwin":
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
def test_get_output_volume(self):
"""
Tests the return of get_output_volume.

View file

@ -8,7 +8,12 @@ from __future__ import absolute_import, print_function, unicode_literals
from salt.exceptions import CommandExecutionError
from salt.ext import six
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, random_string, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
random_string,
runs_on,
skip_if_not_root,
)
from tests.support.unit import skipIf
# Create group name strings for tests
@ -21,19 +26,12 @@ REP_USER_GROUP = random_string("RS-", lowercase=False)
@destructiveTest
@skip_if_not_root
@runs_on(kernel="Darwin")
class MacGroupModuleTest(ModuleCase):
"""
Integration tests for the mac_group module
"""
def setUp(self):
"""
Sets up test requirements
"""
os_grain = self.run_function("grains.item", ["kernel"])
if os_grain["kernel"] not in "Darwin":
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
@skipIf(True, "SLOWTEST skip")
def test_mac_group_add(self):
"""

View file

@ -3,26 +3,21 @@
Validate the mac-keychain module
"""
# Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals
import os
# Import Salt Libs
from salt.exceptions import CommandExecutionError
# Import 3rd-party libs
from salt.ext import six
# Import Salt Testing Libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
from tests.support.helpers import destructiveTest, runs_on, skip_if_not_root
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
@destructiveTest
@skip_if_not_root
@runs_on(kernel="Darwin")
class MacKeychainModuleTest(ModuleCase):
"""
Integration tests for the mac_keychain module
@ -36,15 +31,6 @@ class MacKeychainModuleTest(ModuleCase):
cls.cert_alias = "Salt Test"
cls.passwd = "salttest"
def setUp(self):
"""
Sets up the test requirements
"""
os_grain = self.run_function("grains.item", ["kernel"])
# Must be running on a mac
if os_grain["kernel"] not in "Darwin":
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
def tearDown(self):
"""
Clean up after tests

View file

@ -3,18 +3,18 @@
integration tests for mac_pkgutil
"""
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
# Import Salt libs
import salt.utils.path
import salt.utils.platform
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
# Import Salt Testing libs
from tests.support.helpers import (
destructiveTest,
requires_system_grains,
runs_on,
skip_if_binaries_missing,
skip_if_not_root,
)
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
@ -24,7 +24,9 @@ TEST_PKG_URL = (
TEST_PKG_NAME = "org.macports.MacPorts"
@runs_on(kernel="Darwin")
@skip_if_not_root
@skip_if_binaries_missing("pkgutil")
class MacPkgutilModuleTest(ModuleCase):
"""
Validate the mac_pkgutil module
@ -36,19 +38,14 @@ class MacPkgutilModuleTest(ModuleCase):
RUNTIME_VARS.TMP, "MacPorts-2.3.4-10.11-ElCapitan.pkg"
)
def setUp(self):
@requires_system_grains
def setUp(self, grains): # pylint: disable=arguments-differ
"""
Get current settings
"""
if not salt.utils.platform.is_darwin():
self.skipTest("Test only available on macOS")
if not salt.utils.path.which("pkgutil"):
self.skipTest("Test requires pkgutil binary")
os_release = self.run_function("grains.get", ["osrelease"])
os_release = grains["osrelease"]
self.pkg_name = "com.apple.pkg.BaseSystemResources"
if int(os_release.split(".")[1]) >= 13 and salt.utils.platform.is_darwin():
if int(os_release.split(".")[1]) >= 13:
self.pkg_name = "com.apple.pkg.iTunesX"
def tearDown(self):

View file

@ -3,19 +3,20 @@
integration tests for mac_ports
"""
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt libs
import salt.utils.path
import salt.utils.platform
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
runs_on,
skip_if_binaries_missing,
skip_if_not_root,
)
@skip_if_not_root
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("port")
class MacPortsModuleTest(ModuleCase):
"""
Validate the mac_ports module
@ -27,12 +28,6 @@ class MacPortsModuleTest(ModuleCase):
"""
Get current settings
"""
if not salt.utils.platform.is_darwin():
self.skipTest("Test only available on macOS")
if not salt.utils.path.which("port"):
self.skipTest("Test requires port binary")
self.AGREE_INSTALLED = "agree" in self.run_function("pkg.list_pkgs")
self.run_function("pkg.refresh_db")

View file

@ -3,25 +3,25 @@
integration tests for mac_power
"""
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt libs
import salt.utils.path
import salt.utils.platform
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, flaky, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
flaky,
runs_on,
skip_if_binaries_missing,
skip_if_not_root,
)
from tests.support.unit import skipIf
@skip_if_not_root
@flaky(attempts=10)
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(
not salt.utils.path.which("systemsetup"), "'systemsetup' binary not found in $PATH"
)
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("systemsetup")
class MacPowerModuleTest(ModuleCase):
"""
Validate the mac_power module
@ -164,10 +164,8 @@ class MacPowerModuleTest(ModuleCase):
@skip_if_not_root
@flaky(attempts=10)
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(
not salt.utils.path.which("systemsetup"), "'systemsetup' binary not found in $PATH"
)
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("systemsetup")
class MacPowerModuleTestSleepOnPowerButton(ModuleCase):
"""
Test power.get_sleep_on_power_button
@ -217,10 +215,8 @@ class MacPowerModuleTestSleepOnPowerButton(ModuleCase):
@skip_if_not_root
@flaky(attempts=10)
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(
not salt.utils.path.which("systemsetup"), "'systemsetup' binary not found in $PATH"
)
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("systemsetup")
class MacPowerModuleTestRestartPowerFailure(ModuleCase):
"""
Test power.get_restart_power_failure
@ -269,10 +265,8 @@ class MacPowerModuleTestRestartPowerFailure(ModuleCase):
@skip_if_not_root
@flaky(attempts=10)
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(
not salt.utils.path.which("systemsetup"), "'systemsetup' binary not found in $PATH"
)
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("systemsetup")
class MacPowerModuleTestWakeOnNet(ModuleCase):
"""
Test power.get_wake_on_network
@ -318,9 +312,8 @@ class MacPowerModuleTestWakeOnNet(ModuleCase):
@skip_if_not_root
@flaky(attempts=10)
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(
not salt.utils.path.which("systemsetup"), "'systemsetup' binary not found in $PATH"
)
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("systemsetup")
class MacPowerModuleTestWakeOnModem(ModuleCase):
"""
Test power.get_wake_on_modem

View file

@ -3,23 +3,21 @@
integration tests for mac_service
"""
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt libs
import salt.utils.path
import salt.utils.platform
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
runs_on,
skip_if_binaries_missing,
skip_if_not_root,
)
from tests.support.unit import skipIf
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(not salt.utils.path.which("launchctl"), "Test requires launchctl binary")
@skipIf(not salt.utils.path.which("plutil"), "Test requires plutil binary")
@skip_if_not_root
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("launchctl", "plutil")
class MacServiceModuleTest(ModuleCase):
"""
Validate the mac_service module

View file

@ -7,10 +7,14 @@ from __future__ import absolute_import, print_function, unicode_literals
import datetime
import salt.utils.path
import salt.utils.platform
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, random_string, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
random_string,
runs_on,
skip_if_binaries_missing,
skip_if_not_root,
)
from tests.support.unit import skipIf
TEST_USER = random_string("RS-", lowercase=False)
@ -18,9 +22,8 @@ NO_USER = random_string("RS-", lowercase=False)
@skip_if_not_root
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(not salt.utils.path.which("dscl"), "'dscl' binary not found in $PATH")
@skipIf(not salt.utils.path.which("pwpolicy"), "'pwpolicy' binary not found in $PATH")
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("dscl", "pwpolicy")
class MacShadowModuleTest(ModuleCase):
"""
Validate the mac_shadow module

View file

@ -3,25 +3,21 @@
integration tests for mac_softwareupdate
"""
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt libs
import salt.utils.path
import salt.utils.platform
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
# Import Salt Testing libs
from tests.support.helpers import (
destructiveTest,
runs_on,
skip_if_binaries_missing,
skip_if_not_root,
)
from tests.support.unit import skipIf
@skip_if_not_root
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(
not salt.utils.path.which("softwareupdate"),
"'softwareupdate' binary not found in $PATH",
)
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("softwareupdate")
class MacSoftwareUpdateModuleTest(ModuleCase):
"""
Validate the mac_softwareupdate module

View file

@ -3,19 +3,15 @@
:codeauthor: Nicole Thomas <nicole@saltstack.com>
"""
# Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import random
# Import Salt Libs
import salt.utils.files
from salt.exceptions import CommandExecutionError
# Import Salt Testing Libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
from tests.support.helpers import destructiveTest, runs_on, skip_if_not_root
from tests.support.unit import skipIf
# Module Variables
@ -25,6 +21,7 @@ CONFIG = "/etc/sysctl.conf"
@destructiveTest
@skip_if_not_root
@runs_on(kernel="Darwin")
class DarwinSysctlModuleTest(ModuleCase):
"""
Integration tests for the darwin_sysctl module
@ -35,9 +32,6 @@ class DarwinSysctlModuleTest(ModuleCase):
Sets up the test requirements
"""
super(DarwinSysctlModuleTest, self).setUp()
os_grain = self.run_function("grains.item", ["kernel"])
if os_grain["kernel"] not in "Darwin":
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
# Data needed for cleanup
self.has_conf = False
self.val = self.run_function("sysctl.get", [ASSIGN_CMD])

View file

@ -7,13 +7,13 @@ from __future__ import absolute_import, print_function, unicode_literals
import logging
import salt.utils.path
import salt.utils.platform
from tests.support.case import ModuleCase
from tests.support.helpers import (
destructiveTest,
flaky,
random_string,
runs_on,
skip_if_binaries_missing,
skip_if_not_root,
)
from tests.support.unit import skipIf
@ -27,10 +27,8 @@ SET_SUBNET_NAME = random_string("RS-", lowercase=False)
@skip_if_not_root
@flaky(attempts=10)
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(
not salt.utils.path.which("systemsetup"), "'systemsetup' binary not found in $PATH"
)
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("systemsetup")
class MacSystemModuleTest(ModuleCase):
"""
Validate the mac_system module
@ -241,7 +239,7 @@ class MacSystemModuleTest(ModuleCase):
@skip_if_not_root
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@runs_on(kernel="Darwin")
class MacSystemComputerNameTest(ModuleCase):
def setUp(self):
self.COMPUTER_NAME = self.run_function("system.get_computer_name")

View file

@ -10,30 +10,26 @@ Time sync do the following:
- Set time to 'Do not sync'
"""
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import datetime
# Import Salt libs
import salt.utils.path
import salt.utils.platform
# Import 3rd Party libs
from salt.ext import six
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, flaky, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
flaky,
runs_on,
skip_if_binaries_missing,
skip_if_not_root,
)
from tests.support.unit import skipIf
@skip_if_not_root
@flaky
@skipIf(not salt.utils.platform.is_darwin(), "Test only available on macOS")
@skipIf(
not salt.utils.path.which("systemsetup"), "'systemsetup' binary not found in $PATH"
)
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("systemsetup")
class MacTimezoneModuleTest(ModuleCase):
"""
Validate the mac_timezone module

View file

@ -11,7 +11,12 @@ import salt.ext.six as six
import salt.utils.files
from salt.exceptions import CommandExecutionError
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, random_string, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
random_string,
runs_on,
skip_if_not_root,
)
from tests.support.unit import skipIf
# Create user strings for tests
@ -23,20 +28,12 @@ CHANGE_USER = random_string("RS-", lowercase=False)
@destructiveTest
@skip_if_not_root
@runs_on(kernel="Darwin")
class MacUserModuleTest(ModuleCase):
"""
Integration tests for the mac_user module
"""
def setUp(self):
"""
Sets up test requirements
"""
super(MacUserModuleTest, self).setUp()
os_grain = self.run_function("grains.item", ["kernel"])
if os_grain["kernel"] not in "Darwin":
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
@skipIf(True, "SLOWTEST skip")
def test_mac_user_add(self):
"""

View file

@ -3,21 +3,18 @@
integration tests for mac_xattr
"""
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
# Import Salt libs
import salt.utils.path
import salt.utils.platform
from tests.support.case import ModuleCase
# Import Salt Testing libs
from tests.support.helpers import runs_on, skip_if_binaries_missing
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
@runs_on(kernel="Darwin")
@skip_if_binaries_missing("xattr")
class MacXattrModuleTest(ModuleCase):
"""
Validate the mac_xattr module
@ -32,12 +29,6 @@ class MacXattrModuleTest(ModuleCase):
"""
Create test file for testing extended attributes
"""
if not salt.utils.platform.is_darwin():
self.skipTest("Test only available on macOS")
if not salt.utils.path.which("xattr"):
self.skipTest("Test requires xattr binary")
self.run_function("file.touch", [self.test_file])
def tearDown(self):

View file

@ -3,12 +3,10 @@
Validate the mac-defaults module
"""
# Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt Testing Libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, skip_if_not_root
from tests.support.helpers import destructiveTest, runs_on, skip_if_not_root
DEFAULT_DOMAIN = "com.apple.AppleMultitouchMouse"
DEFAULT_KEY = "MouseHorizontalScroll"
@ -17,20 +15,12 @@ DEFAULT_VALUE = "0"
@destructiveTest
@skip_if_not_root
@runs_on(kernel="Darwin")
class MacDefaultsModuleTest(ModuleCase):
"""
Integration tests for the mac_default module
"""
def setUp(self):
"""
Sets up the test requirements
"""
os_grain = self.run_function("grains.item", ["kernel"])
# Must be running on a mac
if os_grain["kernel"] not in "Darwin":
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
def test_macdefaults_write_read(self):
"""
Tests that writes and reads macdefaults

View file

@ -7,19 +7,17 @@
"""
from __future__ import absolute_import, print_function, unicode_literals
import pytest
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, random_string, skip_if_not_root
from tests.support.helpers import (
destructiveTest,
random_string,
runs_on,
skip_if_not_root,
)
@pytest.mark.skip_unless_on_freebsd
@runs_on(kernel="FreeBSD")
class PwUserModuleTest(ModuleCase):
def setUp(self):
super(PwUserModuleTest, self).setUp()
os_grain = self.run_function("grains.item", ["kernel"])
if os_grain["kernel"] != "FreeBSD":
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
@destructiveTest
@skip_if_not_root
def test_groups_includes_primary(self):

View file

@ -18,19 +18,13 @@ import salt.utils.platform
from salt.ext import six
from salt.ext.six.moves import range
from tests.support.case import ModuleCase
from tests.support.helpers import (
destructiveTest,
flaky,
requires_system_grains,
skip_if_not_root,
)
from tests.support.unit import SkipTest, skipIf
from tests.support.helpers import destructiveTest, flaky, runs_on, skip_if_not_root
from tests.support.unit import skipIf
log = logging.getLogger(__name__)
@skipIf(not salt.utils.platform.is_linux(), "These tests can only be run on linux")
@pytest.mark.windows_whitelisted
@runs_on(kernel="Linux")
class SystemModuleTest(ModuleCase):
"""
Validate the date/time functions in the system module
@ -40,10 +34,7 @@ class SystemModuleTest(ModuleCase):
_systemd_timesyncd_available_ = None
@classmethod
@requires_system_grains
def setUpClass(cls, grains): # pylint: disable=arguments-differ
if grains["kernel"] != "Linux":
raise SkipTest("Test not applicable to '{kernel}' kernel".format(**grains))
def setUpClass(cls):
cls.fmt_str = "%Y-%m-%d %H:%M:%S"
cls._orig_time = None
cls._machine_info = True
@ -404,7 +395,7 @@ class SystemModuleTest(ModuleCase):
self.assertTrue(self._hwclock_has_compare())
@skipIf(not salt.utils.platform.is_windows(), "These tests can only be run on windows")
@runs_on(kernel="Windows")
@pytest.mark.windows_whitelisted
class WinSystemModuleTest(ModuleCase):
"""
@ -475,7 +466,7 @@ class WinSystemModuleTest(ModuleCase):
self.assertEqual(date, ret)
@skipIf(not salt.utils.platform.is_windows(), "These tests can only be run on windows")
@runs_on(kernel="Windows")
@pytest.mark.windows_whitelisted
class WinSystemModuleTimeSettingTest(ModuleCase):
"""

View file

@ -3,28 +3,21 @@
from __future__ import absolute_import, print_function, unicode_literals
import pytest
import salt.utils.platform
from tests.support.case import ModuleCase
from tests.support.helpers import (
destructiveTest,
random_string,
requires_system_grains,
runs_on,
skip_if_not_root,
)
from tests.support.unit import skipIf
@destructiveTest
@skipIf(not salt.utils.platform.is_linux(), "These tests can only be run on linux")
@skip_if_not_root
@pytest.mark.windows_whitelisted
@runs_on(kernel="Linux")
class UseraddModuleTestLinux(ModuleCase):
def setUp(self):
super(UseraddModuleTestLinux, self).setUp()
os_grain = self.run_function("grains.item", ["kernel"])
if os_grain["kernel"] not in ("Linux", "Darwin"):
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
@requires_system_grains
@skipIf(True, "SLOWTEST skip")
def test_groups_includes_primary(self, grains):
@ -93,8 +86,8 @@ class UseraddModuleTestLinux(ModuleCase):
@destructiveTest
@skipIf(not salt.utils.platform.is_windows(), "These tests can only be run on Windows")
@skip_if_not_root
@runs_on(kernel="Windows")
@pytest.mark.windows_whitelisted
class UseraddModuleTestWindows(ModuleCase):
def setUp(self):