Stop using @skipIf

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-12-05 10:10:56 +00:00 committed by Pedro Algarvio
parent 9cf6b752e0
commit d990363f8a
140 changed files with 1091 additions and 1054 deletions

View file

@ -1,10 +1,9 @@
"""
:codeauthor: Nicole Thomas <nicole@saltstack.com>
"""
import os
import pytest
import yaml
import salt.utils.cloud
@ -13,7 +12,6 @@ import salt.utils.yaml
from tests.integration.cloud.helpers.cloud_test_base import CloudTest
from tests.support import win_installer
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
HAS_WINRM = salt.utils.cloud.HAS_WINRM and salt.utils.cloud.HAS_SMB
# THis test needs a longer timeout than other cloud tests
@ -164,7 +162,9 @@ class EC2Test(CloudTest):
)
self._test_instance("ec2-win2012r2-test", debug=True)
@skipIf(not HAS_WINRM, "Skip when winrm dependencies are missing")
@pytest.mark.skipif(
not HAS_WINRM, reason="Skip when winrm dependencies are missing"
)
def test_win2012r2_winrm(self):
"""
Tests creating and deleting a Windows 2012r2 instance on EC2 using
@ -198,7 +198,9 @@ class EC2Test(CloudTest):
)
self._test_instance("ec2-win2016-test", debug=True)
@skipIf(not HAS_WINRM, "Skip when winrm dependencies are missing")
@pytest.mark.skipif(
not HAS_WINRM, reason="Skip when winrm dependencies are missing"
)
def test_win2016_winrm(self):
"""
Tests creating and deleting a Windows 2016 instance on EC2 using winrm

View file

@ -2,12 +2,12 @@
:codeauthor: Nicole Thomas <nicole@saltstack.com>
"""
import logging
import pytest
from salt.utils.versions import LooseVersion
from tests.integration.cloud.helpers.cloud_test_base import CloudTest
from tests.support.unit import skipIf
try:
import azure # pylint: disable=unused-import
@ -39,10 +39,12 @@ def __has_required_azure():
return False
@skipIf(not HAS_AZURE, "These tests require the Azure Python SDK to be installed.")
@skipIf(
@pytest.mark.skipif(
not HAS_AZURE, reason="These tests require the Azure Python SDK to be installed."
)
@pytest.mark.skipif(
not __has_required_azure(),
"The Azure Python SDK must be >= {}.".format(REQUIRED_AZURE),
reason="The Azure Python SDK must be >= {}.".format(REQUIRED_AZURE),
)
class AzureTest(CloudTest):
"""

View file

@ -1,10 +1,9 @@
"""
:codeauthor: :email:`Amel Ajdinovic <amel@stackpointcloud.com>`
"""
import pytest
from tests.integration.cloud.helpers.cloud_test_base import TIMEOUT, CloudTest
from tests.support.unit import skipIf
try:
from oneandone.client import OneAndOneService # pylint: disable=unused-import
@ -14,7 +13,7 @@ except ImportError:
HAS_ONEANDONE = False
@skipIf(HAS_ONEANDONE is False, "salt-cloud requires >= 1and1 1.2.0")
@pytest.mark.skipif(HAS_ONEANDONE is False, reason="salt-cloud requires >= 1and1 1.2.0")
class OneAndOneTest(CloudTest):
"""
Integration tests for the 1and1 cloud provider

View file

@ -9,7 +9,6 @@ import pytest
from tests.integration.cloud.helpers.cloud_test_base import TIMEOUT, CloudTest
from tests.support.case import ModuleCase
from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.unit import skipIf
log = logging.getLogger(__name__)
@ -32,9 +31,9 @@ except ImportError:
HAS_SHADE = False
@skipIf(
@pytest.mark.skipif(
not HAS_KEYSTONE,
"Please install keystoneclient and a keystone server before running"
reason="Please install keystoneclient and a keystone server before running"
"openstack integration tests.",
)
class OpenstackTest(ModuleCase, SaltReturnAssertsMixin):
@ -205,7 +204,7 @@ class OpenstackTest(ModuleCase, SaltReturnAssertsMixin):
self.assertTrue(driver.auth_token)
@skipIf(not HAS_SHADE, "openstack driver requires `shade`")
@pytest.mark.skipif(not HAS_SHADE, reason="openstack driver requires `shade`")
class RackspaceTest(CloudTest):
"""
Integration tests for the Rackspace cloud provider using the Openstack driver

View file

@ -1,10 +1,9 @@
"""
:codeauthor: Ethan Devenport <ethand@stackpointcloud.com>
"""
import pytest
from tests.integration.cloud.helpers.cloud_test_base import TIMEOUT, CloudTest
from tests.support.unit import skipIf
try:
# pylint: disable=unused-import
@ -15,7 +14,9 @@ except ImportError:
HAS_PROFITBRICKS = False
@skipIf(HAS_PROFITBRICKS is False, "salt-cloud requires >= profitbricks 4.1.0")
@pytest.mark.skipif(
HAS_PROFITBRICKS is False, reason="salt-cloud requires >= profitbricks 4.1.0"
)
class ProfitBricksTest(CloudTest):
"""
Integration tests for the ProfitBricks cloud provider

View file

@ -1,11 +1,12 @@
# This code assumes vboxapi.py from VirtualBox distribution
# being in PYTHONPATH, or installed system-wide
import logging
import os
import socket
import pytest
from salt.config import cloud_providers_config, vm_profiles_config
from salt.utils.virtualbox import (
HAS_LIBS,
@ -34,7 +35,7 @@ from tests.integration.cloud.helpers.virtualbox import (
VirtualboxTestCase,
)
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
log = logging.getLogger(__name__)
@ -205,9 +206,11 @@ class VirtualboxProviderTest(VirtualboxCloudTestCase):
vb_destroy_machine(INSTANCE_NAME)
@skipIf(
@pytest.mark.skipif(
HAS_LIBS and vb_machine_exists(BOOTABLE_BASE_BOX_NAME) is False,
"Bootable VM '{}' not found. Cannot run tests.".format(BOOTABLE_BASE_BOX_NAME),
reason="Bootable VM '{}' not found. Cannot run tests.".format(
BOOTABLE_BASE_BOX_NAME
),
)
class VirtualboxProviderHeavyTests(VirtualboxCloudTestCase):
"""
@ -341,7 +344,7 @@ class VirtualboxProviderHeavyTests(VirtualboxCloudTestCase):
self.assertIsIpAddress(ip_address)
@skipIf(HAS_LIBS is False, "The 'vboxapi' library is not available")
@pytest.mark.skipif(HAS_LIBS is False, reason="The 'vboxapi' library is not available")
class BaseVirtualboxTests(TestCase):
def test_get_manager(self):
self.assertIsNotNone(vb_get_box())
@ -379,9 +382,11 @@ class CloneVirtualboxTests(VirtualboxTestCase):
self.assertMachineDoesNotExist(vb_name)
@skipIf(
@pytest.mark.skipif(
HAS_LIBS and vb_machine_exists(BOOTABLE_BASE_BOX_NAME) is False,
"Bootable VM '{}' not found. Cannot run tests.".format(BOOTABLE_BASE_BOX_NAME),
reason="Bootable VM '{}' not found. Cannot run tests.".format(
BOOTABLE_BASE_BOX_NAME
),
)
class BootVirtualboxTests(VirtualboxTestCase):
def test_start_stop(self):

View file

@ -1,10 +1,12 @@
import logging
import pytest
import salt.utils.json
import salt.utils.virtualbox
import tests.integration.cloud.helpers
from tests.support.case import ShellCase
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# Create the cloud instance name to be used throughout the tests
INSTANCE_NAME = tests.integration.cloud.helpers.random_name()
@ -20,7 +22,9 @@ BOOTABLE_BASE_BOX_NAME = "SaltMiniBuntuTest"
log = logging.getLogger(__name__)
@skipIf(salt.utils.virtualbox.HAS_LIBS is False, "virtualbox has to be installed")
@pytest.mark.skipif(
salt.utils.virtualbox.HAS_LIBS is False, reason="virtualbox has to be installed"
)
class VirtualboxTestCase(TestCase):
def setUp(self):
self.vbox = salt.utils.virtualbox.vb_get_box()
@ -43,9 +47,9 @@ class VirtualboxTestCase(TestCase):
)
@skipIf(
@pytest.mark.skipif(
salt.utils.virtualbox.HAS_LIBS is False,
"salt-cloud requires virtualbox to be installed",
reason="salt-cloud requires virtualbox to be installed",
)
class VirtualboxCloudTestCase(ShellCase):
def run_cloud(self, arg_str, catch_stderr=False, timeout=None, config_dir=None):

View file

@ -1,10 +1,9 @@
"""
Validate the boto_iam module
"""
import pytest
from tests.support.case import ModuleCase
from tests.support.unit import skipIf
try:
import boto
@ -14,9 +13,9 @@ except ImportError:
NO_BOTO_MODULE = True
@skipIf(
@pytest.mark.skipif(
NO_BOTO_MODULE,
"Please install the boto library before running boto integration tests.",
reason="Please install the boto library before running boto integration tests.",
)
class BotoIAMTest(ModuleCase):
def setUp(self):

View file

@ -1,12 +1,11 @@
"""
Validate the boto_sns module
"""
import re
import pytest
from tests.support.case import ModuleCase
from tests.support.unit import skipIf
try:
import boto
@ -16,9 +15,9 @@ except ImportError:
NO_BOTO_MODULE = True
@skipIf(
@pytest.mark.skipif(
NO_BOTO_MODULE,
"Please install the boto library before running boto integration tests.",
reason="Please install the boto library before running boto integration tests.",
)
class BotoSNSTest(ModuleCase):
def setUp(self):

View file

@ -20,7 +20,6 @@ import salt.utils.stringutils
from tests.support.case import ModuleCase
from tests.support.helpers import with_tempfile
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
log = logging.getLogger(__name__)
@ -64,10 +63,7 @@ class CPModuleTest(ModuleCase):
self.assertNotIn("bacon", data)
@with_tempfile()
@skipIf(
salt.utils.platform.is_windows(),
"This test hangs on Windows on Py3",
)
@pytest.mark.skip_on_windows(reason="This test hangs on Windows on Py3")
def test_get_file_templated_paths(self, tgt):
"""
cp.get_file

View file

@ -24,7 +24,6 @@ import salt.utils.platform
from salt.utils.versions import LooseVersion
from tests.support.case import ModuleCase
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
log = logging.getLogger(__name__)
@ -869,8 +868,9 @@ class GitModuleTest(ModuleCase):
"refs/heads/master",
)
@skipIf(
not _worktrees_supported(), "Git 2.5 or newer required for worktree support"
@pytest.mark.skipif(
not _worktrees_supported(),
reason="Git 2.5 or newer required for worktree support",
)
@pytest.mark.slow_test
def test_worktree_add_rm(self):

View file

@ -5,12 +5,10 @@ Test the lxc module
import pytest
from tests.support.case import ModuleCase
from tests.support.unit import skipIf
@skipIf(
True,
"Needs rewrite to be more distro agnostic. Also, the tearDown "
@pytest.mark.skip(
reason="Needs rewrite to be more distro agnostic. Also, the tearDown "
"function destroys ALL containers on the box, which is BAD.",
)
@pytest.mark.windows_whitelisted

View file

@ -244,7 +244,7 @@ class MacSystemComputerNameTest(ModuleCase):
# A similar test used to be skipped on py3 due to 'hanging', if we see
# something similar again we may want to skip this gain until we
# investigate
# @skipIf(salt.utils.platform.is_darwin() and six.PY3, 'This test hangs on OS X on Py3. Skipping until #53566 is merged.')
# @pytest.mark.skipif(salt.utils.platform.is_darwin() and six.PY3, reason='This test hangs on OS X on Py3. Skipping until #53566 is merged.')
@pytest.mark.destructive_test
@pytest.mark.slow_test
def test_get_set_computer_name(self):

View file

@ -14,7 +14,6 @@ import datetime
import pytest
from tests.support.case import ModuleCase
from tests.support.unit import skipIf
@pytest.mark.flaky(max_runs=4)
@ -56,9 +55,8 @@ class MacTimezoneModuleTest(ModuleCase):
self.run_function("timezone.set_date", [self.CURRENT_DATE])
self.run_function("timezone.set_time", [self.CURRENT_TIME])
@skipIf(
True,
"Skip until we can figure out why modifying the system clock causes ZMQ errors",
@pytest.mark.skip(
reason="Skip until we can figure out why modifying the system clock causes ZMQ errors",
)
@pytest.mark.destructive_test
def test_get_set_date(self):
@ -86,9 +84,8 @@ class MacTimezoneModuleTest(ModuleCase):
obj_date = datetime.datetime.strptime(text_time, "%H:%M:%S")
self.assertIsInstance(obj_date, datetime.date)
@skipIf(
True,
"Skip until we can figure out why modifying the system clock causes ZMQ errors",
@pytest.mark.skip(
reason="Skip until we can figure out why modifying the system clock causes ZMQ errors",
)
@pytest.mark.destructive_test
def test_set_time(self):
@ -104,9 +101,8 @@ class MacTimezoneModuleTest(ModuleCase):
"ERROR executing 'timezone.set_time': Invalid Date/Time Format: 3:71",
)
@skipIf(
True,
"Skip until we can figure out why modifying the system clock causes ZMQ errors",
@pytest.mark.skip(
reason="Skip until we can figure out why modifying the system clock causes ZMQ errors",
)
@pytest.mark.destructive_test
def test_get_set_zone(self):
@ -124,9 +120,8 @@ class MacTimezoneModuleTest(ModuleCase):
"ERROR executing 'timezone.set_zone': Invalid Timezone: spongebob",
)
@skipIf(
True,
"Skip until we can figure out why modifying the system clock causes ZMQ errors",
@pytest.mark.skip(
reason="Skip until we can figure out why modifying the system clock causes ZMQ errors",
)
@pytest.mark.destructive_test
def test_get_offset(self):
@ -141,9 +136,8 @@ class MacTimezoneModuleTest(ModuleCase):
self.assertIsInstance(self.run_function("timezone.get_offset"), (str,))
self.assertEqual(self.run_function("timezone.get_offset"), "-0700")
@skipIf(
True,
"Skip until we can figure out why modifying the system clock causes ZMQ errors",
@pytest.mark.skip(
reason="Skip until we can figure out why modifying the system clock causes ZMQ errors",
)
@pytest.mark.destructive_test
def test_get_set_zonecode(self):
@ -169,9 +163,8 @@ class MacTimezoneModuleTest(ModuleCase):
self.assertIn("America/Denver", self.run_function("timezone.list_zones"))
self.assertIn("America/Los_Angeles", self.run_function("timezone.list_zones"))
@skipIf(
True,
"Skip until we can figure out why modifying the system clock causes ZMQ errors",
@pytest.mark.skip(
reason="Skip until we can figure out why modifying the system clock causes ZMQ errors",
)
@pytest.mark.destructive_test
def test_zone_compare(self):
@ -182,9 +175,8 @@ class MacTimezoneModuleTest(ModuleCase):
self.assertTrue(self.run_function("timezone.zone_compare", ["America/Denver"]))
self.assertFalse(self.run_function("timezone.zone_compare", ["Pacific/Wake"]))
@skipIf(
True,
"Skip until we can figure out why modifying the system clock causes ZMQ errors",
@pytest.mark.skip(
reason="Skip until we can figure out why modifying the system clock causes ZMQ errors",
)
@pytest.mark.destructive_test
def test_get_set_using_network_time(self):
@ -198,9 +190,8 @@ class MacTimezoneModuleTest(ModuleCase):
self.assertTrue(self.run_function("timezone.set_using_network_time", [False]))
self.assertFalse(self.run_function("timezone.get_using_network_time"))
@skipIf(
True,
"Skip until we can figure out why modifying the system clock causes ZMQ errors",
@pytest.mark.skip(
reason="Skip until we can figure out why modifying the system clock causes ZMQ errors",
)
@pytest.mark.destructive_test
def test_get_set_time_server(self):

View file

@ -6,7 +6,6 @@ import salt.utils.path
from salt.modules import mysql as mysqlmod
from tests.support.case import ModuleCase
from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.unit import skipIf
log = logging.getLogger(__name__)
@ -20,9 +19,9 @@ if not salt.utils.path.which("mysqladmin"):
NO_MYSQL = True
@skipIf(
@pytest.mark.skipif(
NO_MYSQL,
"Please install MySQL bindings and a MySQL Server before running"
reason="Please install MySQL bindings and a MySQL Server before running "
"MySQL integration tests.",
)
@pytest.mark.windows_whitelisted
@ -641,9 +640,9 @@ class MysqlModuleDbTest(ModuleCase, SaltReturnAssertsMixin):
self.assertEqual(True, ret)
@skipIf(
@pytest.mark.skipif(
NO_MYSQL,
"Please install MySQL bindings and a MySQL Server before running"
reason="Please install MySQL bindings and a MySQL Server before running "
"MySQL integration tests.",
)
@pytest.mark.windows_whitelisted
@ -1312,9 +1311,9 @@ class MysqlModuleUserTest(ModuleCase, SaltReturnAssertsMixin):
self.assertNotIn({"Host": "10.0.0.1", "User": user6_utf8}, ret)
@skipIf(
@pytest.mark.skipif(
NO_MYSQL,
"Please install MySQL bindings and a MySQL Server before running"
reason="Please install MySQL bindings and a MySQL Server before running "
"MySQL integration tests.",
)
@pytest.mark.windows_whitelisted
@ -1690,9 +1689,9 @@ class MysqlModuleUserGrantTest(ModuleCase, SaltReturnAssertsMixin):
)
@skipIf(
@pytest.mark.skipif(
NO_MYSQL,
"Please install MySQL bindings and a MySQL Server before running"
reason="Please install MySQL bindings and a MySQL Server before running "
"MySQL integration tests.",
)
@pytest.mark.windows_whitelisted

View file

@ -14,7 +14,6 @@ import salt.utils.files
import salt.utils.platform
from tests.support.case import ModuleCase
from tests.support.helpers import requires_system_grains
from tests.support.unit import skipIf
try:
import pyiface
@ -31,8 +30,12 @@ INTERFACE_FOR_TEST = "eth1"
@pytest.mark.skip_if_not_root
@skipIf(not pyiface, "The python pyiface package is not installed")
@skipIf(not CaseInsensitiveDict, "The python package requests is not installed")
@pytest.mark.skipif(
pyiface is None, reason="The python pyiface package is not installed"
)
@pytest.mark.skipif(
CaseInsensitiveDict is None, reason="The python package requests is not installed"
)
@pytest.mark.destructive_test
class NilrtIpModuleTest(ModuleCase):
"""
@ -43,7 +46,9 @@ class NilrtIpModuleTest(ModuleCase):
@classmethod
def setUpClass(cls, grains): # pylint: disable=arguments-differ
if grains["os_family"] != "NILinuxRT":
pytest.skip(reason="Tests applicable only to NILinuxRT")
raise pytest.skip.Exception(
"Tests applicable only to NILinuxRT", _use_item_location=True
)
cls.initialState = {}
cls.grains = grains

View file

@ -20,12 +20,9 @@ from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
from tests.support.case import ModuleCase
from tests.support.helpers import patched_environ
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
@skipIf(
salt.utils.path.which_bin(KNOWN_BINARY_NAMES) is None, "virtualenv not installed"
)
@pytest.mark.skip_if_binaries_missing(*KNOWN_BINARY_NAMES, check_all=False)
@pytest.mark.windows_whitelisted
class PipModuleTest(ModuleCase):
def setUp(self):
@ -590,11 +587,12 @@ class PipModuleTest(ModuleCase):
" Dictionary: {}".format(exc, pprint.pformat(ret))
)
@skipIf(not os.path.isfile("pip3"), "test where pip3 is installed")
@skipIf(
salt.utils.platform.is_windows(), "test specific for linux usage of /bin/python"
@pytest.mark.skipif(
shutil.which("/bin/pip3") is None, reason="Could not find /bin/pip3"
)
@pytest.mark.skip_on_windows(reason="test specific for linux usage of /bin/python")
def test_system_pip3(self):
self.run_function(
"pip.install", pkgs=["lazyimport==0.0.1"], bin_env="/bin/pip3"
)

View file

@ -128,8 +128,7 @@ class SSHModuleTest(ModuleCase):
"AssertionError: {}. Function returned: {}".format(exc, ret)
)
@pytest.mark.skipif(
salt.utils.platform.is_photonos() is True,
@pytest.mark.skip_on_photonos(
reason="Skip on PhotonOS. Attempting to receive the SSH key from Github, using RSA keys which are disabled.",
)
@pytest.mark.slow_test
@ -219,8 +218,7 @@ class SSHModuleTest(ModuleCase):
ret = self.run_function("ssh.check_known_host", arg, **kwargs)
self.assertEqual(ret, "add")
@pytest.mark.skipif(
salt.utils.platform.is_photonos() is True,
@pytest.mark.skip_on_photonos(
reason="Skip on PhotonOS. Attempting to receive the SSH key from Github, using RSA keys which are disabled.",
)
@pytest.mark.slow_test

View file

@ -4,16 +4,12 @@ import time
import pytest
import salt.utils.path
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
from tests.support.case import ModuleCase
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
@skipIf(
salt.utils.path.which_bin(KNOWN_BINARY_NAMES) is None, "virtualenv not installed"
)
@pytest.mark.skip_if_binaries_missing(*KNOWN_BINARY_NAMES, check_all=False)
@pytest.mark.skip_if_binaries_missing("supervisorctl")
class SupervisordModuleTest(ModuleCase):
"""

View file

@ -70,9 +70,7 @@ import sys
import pytest
from distro import linux_distribution
import salt.utils.path
import salt.utils.platform
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES as VIRTUALENV_NAMES
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
from salt.utils.gitfs import (
GITPYTHON_MINVER,
GITPYTHON_VERSION,
@ -92,7 +90,6 @@ from tests.support.gitfs import ( # pylint: disable=unused-import
webserver_pillar_tests_prep_authenticated,
)
from tests.support.helpers import SKIP_INITIAL_PHOTONOS_FAILURES, requires_system_grains
from tests.support.unit import skipIf
# Check for requisite components
try:
@ -105,10 +102,6 @@ try:
except Exception: # pylint: disable=broad-except
HAS_PYGIT2 = False
HAS_SSHD = bool(salt.utils.path.which("sshd"))
HAS_NGINX = bool(salt.utils.path.which("nginx"))
HAS_VIRTUALENV = bool(salt.utils.path.which_bin(VIRTUALENV_NAMES))
pytestmark = [
SKIP_INITIAL_PHOTONOS_FAILURES,
pytest.mark.skip_on_platforms(windows=True, darwin=True),
@ -693,11 +686,13 @@ class GitPythonMixin:
self.assertEqual(excinfo.exception.strerror, "Failed to load git_pillar")
@skipIf(not HAS_GITPYTHON, "GitPython >= {} required".format(GITPYTHON_MINVER))
@skipIf(not HAS_SSHD, "sshd not present")
@pytest.mark.skipif(
not HAS_GITPYTHON, reason="GitPython >= {} required".format(GITPYTHON_MINVER)
)
@pytest.mark.usefixtures("ssh_pillar_tests_prep")
@pytest.mark.destructive_test
@pytest.mark.skip_if_not_root
@pytest.mark.skip_if_binaries_missing("sshd")
class TestGitPythonSSH(GitPillarSSHTestBase, GitPythonMixin):
"""
Test git_pillar with GitPython using SSH authentication
@ -709,22 +704,26 @@ class TestGitPythonSSH(GitPillarSSHTestBase, GitPythonMixin):
passphrase = PASSWORD
@skipIf(not HAS_GITPYTHON, "GitPython >= {} required".format(GITPYTHON_MINVER))
@skipIf(not HAS_NGINX, "nginx not present")
@skipIf(not HAS_VIRTUALENV, "virtualenv not present")
@pytest.mark.skipif(
not HAS_GITPYTHON, reason="GitPython >= {} required".format(GITPYTHON_MINVER)
)
@pytest.mark.usefixtures("webserver_pillar_tests_prep")
@pytest.mark.skip_if_not_root
@pytest.mark.skip_if_binaries_missing("nginx")
@pytest.mark.skip_if_binaries_missing(*KNOWN_BINARY_NAMES, check_all=False)
class TestGitPythonHTTP(GitPillarHTTPTestBase, GitPythonMixin):
"""
Test git_pillar with GitPython using unauthenticated HTTP
"""
@skipIf(not HAS_GITPYTHON, "GitPython >= {} required".format(GITPYTHON_MINVER))
@skipIf(not HAS_NGINX, "nginx not present")
@skipIf(not HAS_VIRTUALENV, "virtualenv not present")
@pytest.mark.skipif(
not HAS_GITPYTHON, reason="GitPython >= {} required".format(GITPYTHON_MINVER)
)
@pytest.mark.usefixtures("webserver_pillar_tests_prep_authenticated")
@pytest.mark.skip_if_not_root
@pytest.mark.skip_if_binaries_missing("nginx")
@pytest.mark.skip_if_binaries_missing(*KNOWN_BINARY_NAMES, check_all=False)
class TestGitPythonAuthenticatedHTTP(TestGitPythonHTTP, GitPythonMixin):
"""
Test git_pillar with GitPython using authenticated HTTP
@ -734,13 +733,16 @@ class TestGitPythonAuthenticatedHTTP(TestGitPythonHTTP, GitPythonMixin):
password = PASSWORD
@skipIf(salt.utils.platform.is_aarch64(), "Test is broken on aarch64")
@skipIf(_centos_stream_9(), "CentOS Stream 9 has RSA keys disabled by default")
@skipIf(
not HAS_PYGIT2,
"pygit2 >= {} and libgit2 >= {} required".format(PYGIT2_MINVER, LIBGIT2_MINVER),
@pytest.mark.skip_on_aarch64(reason="Test is broken on aarch64")
@pytest.mark.skipif(
_centos_stream_9(), reason="CentOS Stream 9 has RSA keys disabled by default"
)
@pytest.mark.skipif(
not HAS_PYGIT2,
reason="pygit2 >= {} and libgit2 >= {} required".format(
PYGIT2_MINVER, LIBGIT2_MINVER
),
)
@skipIf(not HAS_SSHD, "sshd not present")
@pytest.mark.usefixtures("ssh_pillar_tests_prep")
@pytest.mark.destructive_test
@pytest.mark.skip_if_not_root
@ -751,6 +753,7 @@ class TestGitPythonAuthenticatedHTTP(TestGitPythonHTTP, GitPythonMixin):
"See https://github.com/saltstack/salt/issues/61704"
),
)
@pytest.mark.skip_if_binaries_missing("sshd")
class TestPygit2SSH(GitPillarSSHTestBase):
"""
Test git_pillar with pygit2 using SSH authentication
@ -2350,14 +2353,16 @@ class TestPygit2SSH(GitPillarSSHTestBase):
self.assertEqual(excinfo.exception.strerror, "Failed to load git_pillar")
@skipIf(
@pytest.mark.skipif(
not HAS_PYGIT2,
"pygit2 >= {} and libgit2 >= {} required".format(PYGIT2_MINVER, LIBGIT2_MINVER),
reason="pygit2 >= {} and libgit2 >= {} required".format(
PYGIT2_MINVER, LIBGIT2_MINVER
),
)
@skipIf(not HAS_NGINX, "nginx not present")
@skipIf(not HAS_VIRTUALENV, "virtualenv not present")
@pytest.mark.usefixtures("webserver_pillar_tests_prep")
@pytest.mark.skip_if_not_root
@pytest.mark.skip_if_binaries_missing("nginx")
@pytest.mark.skip_if_binaries_missing(*KNOWN_BINARY_NAMES, check_all=False)
class TestPygit2HTTP(GitPillarHTTPTestBase):
"""
Test git_pillar with pygit2 using SSH authentication
@ -2914,14 +2919,16 @@ class TestPygit2HTTP(GitPillarHTTPTestBase):
self.assertEqual(excinfo.exception.strerror, "Failed to load git_pillar")
@skipIf(
@pytest.mark.skipif(
not HAS_PYGIT2,
"pygit2 >= {} and libgit2 >= {} required".format(PYGIT2_MINVER, LIBGIT2_MINVER),
reason="pygit2 >= {} and libgit2 >= {} required".format(
PYGIT2_MINVER, LIBGIT2_MINVER
),
)
@skipIf(not HAS_NGINX, "nginx not present")
@skipIf(not HAS_VIRTUALENV, "virtualenv not present")
@pytest.mark.usefixtures("webserver_pillar_tests_prep_authenticated")
@pytest.mark.skip_if_not_root
@pytest.mark.skip_if_binaries_missing("nginx")
@pytest.mark.skip_if_binaries_missing(*KNOWN_BINARY_NAMES, check_all=False)
class TestPygit2AuthenticatedHTTP(GitPillarHTTPTestBase):
"""
Test git_pillar with pygit2 using SSH authentication

View file

@ -8,7 +8,6 @@ import sys
import pytest
from tests.support.case import ShellCase
from tests.support.unit import skipIf
try:
import libnacl.sealed # pylint: disable=unused-import
@ -21,8 +20,10 @@ except (ImportError, OSError, AttributeError):
log = logging.getLogger(__name__)
@skipIf(not HAS_LIBNACL, "skipping test_nacl, libnacl is unavailable")
@skipIf(sys.version_info >= (3, 10), "Segfaults with python 3")
@pytest.mark.skipif(
not HAS_LIBNACL, reason="skipping test_nacl, reason=libnacl is unavailable"
)
@pytest.mark.skipif(sys.version_info >= (3, 10), reason="Segfaults with python 3")
@pytest.mark.windows_whitelisted
class NaclTest(ShellCase):
"""

View file

@ -9,14 +9,15 @@ import pytest
from tests.support.case import ModuleCase
from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
NO_ALTERNATIVES = False
if not os.path.exists("/etc/alternatives"):
NO_ALTERNATIVES = True
@skipIf(NO_ALTERNATIVES, "/etc/alternatives does not exist on the system")
@pytest.mark.skipif(
NO_ALTERNATIVES, reason="/etc/alternatives does not exist on the system"
)
class AlterantivesStateTest(ModuleCase, SaltReturnAssertsMixin):
@pytest.mark.destructive_test
@pytest.mark.slow_test

View file

@ -1,13 +1,12 @@
"""
Tests for the boto_sns state
"""
import re
import pytest
from tests.support.case import ModuleCase
from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.unit import skipIf
try:
import boto
@ -17,9 +16,9 @@ except ImportError:
NO_BOTO_MODULE = True
@skipIf(
@pytest.mark.skipif(
NO_BOTO_MODULE,
"Please install the boto library before running boto integration tests.",
reason="Please install the boto library before running boto integration tests.",
)
class BotoSNSTest(ModuleCase, SaltReturnAssertsMixin):
def setUp(self):

View file

@ -8,7 +8,6 @@ import pytest
from tests.support.case import ModuleCase
from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.unit import skipIf
log = logging.getLogger(__name__)
@ -19,9 +18,9 @@ except ImportError:
NO_KEYSTONE = True
@skipIf(
@pytest.mark.skipif(
NO_KEYSTONE,
"Please install keystoneclient and a keystone server before running"
reason="Please install keystoneclient and a keystone server before running "
"keystone integration tests.",
)
class KeystoneStateTest(ModuleCase, SaltReturnAssertsMixin):

View file

@ -7,7 +7,6 @@ import pytest
import salt.utils.path
from tests.support.case import ModuleCase
from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.unit import skipIf
NO_MYSQL = False
try:
@ -19,9 +18,9 @@ if not salt.utils.path.which("mysqladmin"):
NO_MYSQL = True
@skipIf(
@pytest.mark.skipif(
NO_MYSQL,
"Please install MySQL bindings and a MySQL Server before running"
reason="Please install MySQL bindings and a MySQL Server before running "
"MySQL integration tests.",
)
class MysqlDatabaseStateTest(ModuleCase, SaltReturnAssertsMixin):

View file

@ -10,7 +10,6 @@ import salt.utils.path
from salt.modules import mysql as mysqlmod
from tests.support.case import ModuleCase
from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.unit import skipIf
log = logging.getLogger(__name__)
@ -24,9 +23,9 @@ if not salt.utils.path.which("mysqladmin"):
NO_MYSQL = True
@skipIf(
@pytest.mark.skipif(
NO_MYSQL,
"Please install MySQL bindings and a MySQL Server before running"
reason="Please install MySQL bindings and a MySQL Server before running "
"MySQL integration tests.",
)
class MysqlGrantsStateTest(ModuleCase, SaltReturnAssertsMixin):

View file

@ -10,17 +10,13 @@ import time
import pytest
import salt.utils.path
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
from tests.support.case import ModuleCase
from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
@skipIf(
salt.utils.path.which_bin(KNOWN_BINARY_NAMES) is None, "virtualenv not installed"
)
@pytest.mark.skip_if_binaries_missing(*KNOWN_BINARY_NAMES, check_all=False)
@pytest.mark.skip_if_binaries_missing("supervisorctl")
class SupervisordTest(ModuleCase, SaltReturnAssertsMixin):
"""

View file

@ -12,7 +12,6 @@ from tests.support.case import ModuleCase
from tests.support.helpers import with_tempfile
from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
try:
import M2Crypto # pylint: disable=W0611
@ -25,7 +24,7 @@ log = logging.getLogger(__name__)
@pytest.mark.usefixtures("salt_sub_minion")
@skipIf(not HAS_M2CRYPTO, "Skip when no M2Crypto found")
@pytest.mark.skipif(not HAS_M2CRYPTO, reason="Skip when no M2Crypto found")
class x509Test(ModuleCase, SaltReturnAssertsMixin):
@classmethod
def setUpClass(cls):

View file

@ -3,15 +3,16 @@ Test utility methods that the idem module and state share
"""
from contextlib import contextmanager
import pytest
import salt.utils.idem as idem
import salt.utils.path
from tests.support.case import TestCase
from tests.support.unit import skipIf
HAS_IDEM = not salt.utils.path.which("idem")
@skipIf(not idem.HAS_POP[0], str(idem.HAS_POP[1]))
@pytest.mark.skipif(not idem.HAS_POP[0], reason=str(idem.HAS_POP[1]))
@contextmanager
class TestIdem(TestCase):
@classmethod
@ -26,20 +27,20 @@ class TestIdem(TestCase):
with self.subTest(sub=sub):
assert hasattr(self.hub, sub)
@skipIf(not HAS_IDEM, "idem is not installed")
@pytest.mark.skipif(not HAS_IDEM, reason="idem is not installed")
def test_idem_ex(self):
assert hasattr(self.hub.idem, "ex")
@skipIf(not HAS_IDEM, "idem is not installed")
@pytest.mark.skipif(not HAS_IDEM, reason="idem is not installed")
def test_idem_state_apply(self):
assert hasattr(self.hub.idem.state, "apply")
@skipIf(not HAS_IDEM, "idem is not installed")
@pytest.mark.skipif(not HAS_IDEM, reason="idem is not installed")
def test_idem_exec(self):
# self.hub.exec.test.ping() causes a pylint error because of "exec" in the namespace
assert getattr(self.hub, "exec").test.ping()
@skipIf(not HAS_IDEM, "idem is not installed")
@pytest.mark.skipif(not HAS_IDEM, reason="idem is not installed")
def test_idem_state(self):
ret = self.hub.states.test.succeed_without_changes({}, "test_state")
assert ret["result"] is True

View file

@ -4,17 +4,19 @@ Test utility methods that communicate with SMB shares.
import getpass
import logging
import os
import shutil
import signal
import subprocess
import tempfile
import time
import pytest
import salt.utils.files
import salt.utils.network
import salt.utils.path
import salt.utils.smb
from tests.support.case import TestCase
from tests.support.unit import skipIf
log = logging.getLogger(__name__)
CONFIG = (
@ -54,23 +56,10 @@ TBE = (
IPV6_ENABLED = bool(salt.utils.network.ip_addrs6(include_loopback=True))
def which_smbd():
"""
Find the smbd executable and cache the result if it exits.
"""
if hasattr(which_smbd, "cached_result"):
return which_smbd.cached_result
smbd = salt.utils.path.which("smbd")
if smbd:
which_smbd.cached_result = smbd
return smbd
@skipIf(not which_smbd(), reason="smbd binary not found")
@skipIf(
not salt.utils.smb.HAS_SMBPROTOCOL,
'"smbprotocol" needs to be installed.',
@pytest.mark.skipif(
not salt.utils.smb.HAS_SMBPROTOCOL, reason='"smbprotocol" needs to be installed.'
)
@pytest.mark.skip_if_binaries_missing("smbd")
class TestSmb(TestCase):
_smbd = None
@ -107,7 +96,9 @@ class TestSmb(TestCase):
user=cls.username,
)
)
cls._smbd = subprocess.Popen([which_smbd(), "-FS", "-P0", "-s", samba_conf])
cls._smbd = subprocess.Popen(
[shutil.which("smbd"), "-FS", "-P0", "-s", samba_conf]
)
time.sleep(1)
pidfile = os.path.join(cls.samba_dir, "smbd.pid")
with salt.utils.files.fopen(pidfile, "r") as fp:
@ -141,7 +132,7 @@ class TestSmb(TestCase):
result = fp.read()
assert result == content
@skipIf(not IPV6_ENABLED, "IPv6 not enabled")
@pytest.mark.skipif(not IPV6_ENABLED, reason="IPv6 not enabled")
def test_write_file_ipv6(self):
"""
Transfer a file over SMB
@ -180,7 +171,7 @@ class TestSmb(TestCase):
result = fp.read()
assert result == content
@skipIf(not IPV6_ENABLED, "IPv6 not enabled")
@pytest.mark.skipif(not IPV6_ENABLED, reason="IPv6 not enabled")
def test_write_str_v6(self):
"""
Write a string to a file over SMB
@ -215,7 +206,7 @@ class TestSmb(TestCase):
assert not os.path.exists(share_path)
@skipIf(not IPV6_ENABLED, "IPv6 not enabled")
@pytest.mark.skipif(not IPV6_ENABLED, reason="IPv6 not enabled")
def test_delete_file_v6(self):
"""
Validate deletion of files over SMB
@ -247,7 +238,7 @@ class TestSmb(TestCase):
assert os.path.exists(share_path)
@skipIf(not IPV6_ENABLED, "IPv6 not enabled")
@pytest.mark.skipif(not IPV6_ENABLED, reason="IPv6 not enabled")
def test_mkdirs_v6(self):
"""
Create directories over SMB
@ -283,7 +274,7 @@ class TestSmb(TestCase):
assert not os.path.exists(local_path)
assert not os.path.exists(os.path.join(self.public_dir, dir_name))
@skipIf(not IPV6_ENABLED, "IPv6 not enabled")
@pytest.mark.skipif(not IPV6_ENABLED, reason="IPv6 not enabled")
def test_delete_dirs_v6(self):
"""
Validate deletion of directoreies over SMB
@ -312,7 +303,7 @@ class TestSmb(TestCase):
conn = salt.utils.smb.get_conn("127.0.0.1", self.username, "foo", port=1445)
conn.close()
@skipIf(not IPV6_ENABLED, "IPv6 not enabled")
@pytest.mark.skipif(not IPV6_ENABLED, reason="IPv6 not enabled")
def test_connection_v6(self):
"""
Validate creation of an SMB connection

View file

@ -9,6 +9,7 @@ import threading
import time
import traceback
import pytest
import yaml
import salt.utils.files
@ -17,7 +18,6 @@ from tests.support.case import ModuleCase
from tests.support.helpers import with_system_user
from tests.support.mock import Mock
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
try:
import servicemanager
@ -271,7 +271,7 @@ def wait_for_service(name, timeout=200):
time.sleep(0.3)
@skipIf(not HAS_WIN32, "This test runs only on windows.")
@pytest.mark.skipif(not HAS_WIN32, reason="This test runs only on windows.")
class RunAsTest(ModuleCase):
@classmethod
def setUpClass(cls):

View file

@ -85,8 +85,8 @@ def test_is_installed(pkgutil, pkg_name):
assert not pkgutil.is_installed("spongebob")
@pytest.mark.skipif(
True, reason="I don't know how to fix this test. Pedro(s0undt3ch), 2022-04-08"
@pytest.mark.skip(
reason="I don't know how to fix this test. Pedro(s0undt3ch), 2022-04-08"
)
def test_install_forget(
tmp_path,

View file

@ -210,16 +210,12 @@ def test_owner(modules):
"""
test finding the package owning a file
"""
func = "pkg.owner"
ret = modules.pkg.owner("/bin/ls")
assert len(ret) != 0
# Similar to pkg.owner, but for FreeBSD's pkgng
@pytest.mark.skipif(
not salt.utils.platform.is_freebsd(),
reason="test for new package manager for FreeBSD",
)
@pytest.mark.skip_on_freebsd(reason="test for new package manager for FreeBSD")
@pytest.mark.requires_salt_modules("pkg.which")
def test_which(modules):
"""
@ -260,8 +256,7 @@ def test_install_remove(modules, test_pkg, refresh_db):
@pytest.mark.destructive_test
@pytest.mark.skipif(
salt.utils.platform.is_photonos(),
@pytest.mark.skip_on_photonos(
reason="package hold/unhold unsupported on Photon OS",
)
@pytest.mark.requires_salt_modules(
@ -455,10 +450,8 @@ def test_pkg_upgrade_has_pending_upgrades(grains, modules, test_pkg, refresh_db)
@pytest.mark.destructive_test
@pytest.mark.skipif(
salt.utils.platform.is_darwin() is True,
reason="The jenkins user is equivalent to root on mac, causing the test to be"
" unrunnable",
@pytest.mark.skip_on_darwin(
reason="The jenkins user is equivalent to root on mac, causing the test to be unrunnable"
)
@pytest.mark.requires_salt_modules("pkg.remove", "pkg.latest_version")
@pytest.mark.slow_test

View file

@ -6,7 +6,6 @@ from saltfactories.utils import random_string
import salt.modules.useradd as useradd
import salt.utils.platform
from salt.exceptions import CommandExecutionError
from tests.support.unit import skipIf
pytestmark = [
pytest.mark.skip_if_not_root,
@ -78,9 +77,10 @@ def test_info_after_deletion(user, account):
assert not user.info(account.username)
@skipIf(
not (salt.utils.platform.is_darwin() or salt.utils.platform.is_windows()),
"This test should only run (and raise an expected exception) on Windows/Mac due to lack of useradd command",
@pytest.mark.skip_unless_on_platforms(
darwin=True,
windows=True,
reason="This test should only run (and raise an expected exception) on Windows/Mac due to lack of useradd command",
)
def test_errors_out_when_no_useradd_exists(username):
"""

View file

@ -78,8 +78,7 @@ def npm_version(shell, install_npm):
return ret.stdout.strip()
@pytest.mark.skipif(
True,
@pytest.mark.skip(
reason="This test tries to install from a git repo using ssh, at least now. Skipping.",
)
@pytest.mark.skip_if_not_root

View file

@ -679,8 +679,7 @@ def test_pkg_016_conditionally_ignore_epoch(PKG_EPOCH_TARGETS, latest_version, s
assert ret.result is True
@pytest.mark.skipif(
salt.utils.platform.is_photonos(),
@pytest.mark.skip_on_photonos(
reason="package hold/unhold unsupported on Photon OS",
)
@pytest.mark.requires_salt_modules(

View file

@ -1,5 +1,4 @@
import pathlib
import sys
import attr
import pytest
@ -11,9 +10,6 @@ from salt.ext.tornado import locks
pytestmark = [
# Windows does not support POSIX IPC
pytest.mark.skip_on_windows,
pytest.mark.skipif(
sys.version_info < (3, 6), reason="The IOLoop blocks under Py3.5 on these tests"
),
]

View file

@ -29,8 +29,9 @@ def dupegroup(user):
yield _group
@pytest.mark.skipif(
salt.utils.platform.is_darwin() or salt.utils.platform.is_freebsd(),
@pytest.mark.skip_on_platforms(
darwin=True,
freebsd=True,
reason="This test should not run on FreeBSD and Mac due to lack of duplicate GID support",
)
def test_get_group_list_with_duplicate_gid_group(user, dupegroup):

View file

@ -252,8 +252,7 @@ def test_enable(salt_call_cli, disabled_beacon):
@pytest.mark.skipif(
PRE_PYTEST_SKIP_OR_NOT,
reason=(
"Skip until https://github.com/saltstack/salt/issues/31516 problems are"
" resolved."
"Skip until https://github.com/saltstack/salt/issues/31516 problems are resolved."
),
)
def test_enabled_beacons(salt_call_cli, beacon):

View file

@ -255,14 +255,6 @@ def test_egg(virtualenv, cache_dir, use_static_requirements, src_dir):
)
# On python 3.5 Windows sdist fails with encoding errors. This is resolved
# in later versions.
@pytest.mark.skipif(
salt.utils.platform.is_windows()
and sys.version_info > (3,)
and sys.version_info < (3, 6),
reason="Skip on python 3.5",
)
def test_sdist(virtualenv, cache_dir, use_static_requirements, src_dir):
"""
test building and installing a sdist package

View file

@ -1,15 +1,11 @@
# Python libs
import logging
import os
import pytest
# Salt libs
import salt.utils.files
from salt.beacons import inotify
# Third-party libs
try:
import pyinotify # pylint: disable=unused-import
@ -65,8 +61,7 @@ def test_files_list_config():
assert ret == _expected
@pytest.mark.skipif(
salt.utils.platform.is_freebsd() is True,
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
def test_file_open():
@ -86,8 +81,7 @@ def test_file_open():
assert ret[0]["change"] == "IN_OPEN"
@pytest.mark.skipif(
salt.utils.platform.is_freebsd() is True,
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
def test_dir_no_auto_add(tmp_path):
@ -110,8 +104,7 @@ def test_dir_no_auto_add(tmp_path):
assert ret == []
@pytest.mark.skipif(
salt.utils.platform.is_freebsd() is True,
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
def test_dir_auto_add(tmp_path):
@ -140,8 +133,7 @@ def test_dir_auto_add(tmp_path):
assert ret[0]["change"] == "IN_OPEN"
@pytest.mark.skipif(
salt.utils.platform.is_freebsd() is True,
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
def test_dir_recurse(tmp_path):
@ -170,8 +162,7 @@ def test_dir_recurse(tmp_path):
assert ret[2]["change"] == "IN_OPEN"
@pytest.mark.skipif(
salt.utils.platform.is_freebsd() is True,
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
def test_dir_recurse_auto_add(tmp_path):
@ -213,8 +204,7 @@ def test_dir_recurse_auto_add(tmp_path):
assert ret[0]["change"] == "IN_DELETE"
@pytest.mark.skipif(
salt.utils.platform.is_freebsd() is True,
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
def test_multi_files_exclude(tmp_path):

View file

@ -56,8 +56,7 @@ def test_empty_config():
assert ret == []
@pytest.mark.skipif(
salt.utils.platform.is_freebsd(),
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
def test_file_create(tmp_path):
@ -122,8 +121,7 @@ def test_file_deleted(tmp_path):
assert ret[0]["change"] == "deleted"
@pytest.mark.skipif(
salt.utils.platform.is_freebsd(),
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
def test_file_moved(tmp_path):
@ -142,8 +140,7 @@ def test_file_moved(tmp_path):
assert ret[0]["change"] == "moved"
@pytest.mark.skipif(
salt.utils.platform.is_freebsd(),
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
def test_file_create_in_directory(tmp_path):
@ -160,8 +157,7 @@ def test_file_create_in_directory(tmp_path):
assert ret[0]["change"] == "created"
@pytest.mark.skipif(
salt.utils.platform.is_freebsd(),
@pytest.mark.skip_on_freebsd(
reason="Skip on FreeBSD - does not yet have full inotify/watchdog support",
)
@pytest.mark.slow_test

View file

@ -339,9 +339,7 @@ def test_run_ssh_pre_flight(opts, target, tmp_path):
] == mock_cmd.call_args_list
@pytest.mark.skipif(
salt.utils.platform.is_windows(), reason="SSH_PY_SHIM not set on windows"
)
@pytest.mark.skip_on_windows(reason="SSH_PY_SHIM not set on windows")
@pytest.mark.slow_test
def test_cmd_run_set_path(opts, target):
"""
@ -363,9 +361,7 @@ def test_cmd_run_set_path(opts, target):
assert re.search("\\" + target["set_path"], ret)
@pytest.mark.skipif(
salt.utils.platform.is_windows(), reason="SSH_PY_SHIM not set on windows"
)
@pytest.mark.skip_on_windows(reason="SSH_PY_SHIM not set on windows")
@pytest.mark.slow_test
def test_cmd_run_not_set_path(opts, target):
"""

View file

@ -622,9 +622,7 @@ def test_image_clone_no_image_id_or_image_name():
)
@pytest.mark.skipif(
True, reason="Need to figure out how to mock calls to the O.N. API first."
)
@pytest.mark.skip(reason="Need to figure out how to mock calls to the O.N. API first.")
def test_image_clone_success():
"""
Tests that image_clone returns successfully

View file

@ -171,8 +171,7 @@ def test_dynamic_file_roots(tmp_path):
assert "dynamo.sls" in ret2
@pytest.mark.skipif(
salt.utils.platform.is_windows(),
@pytest.mark.skip_on_windows(
reason="Windows does not support this master function",
)
def test_update_no_change():

View file

@ -100,9 +100,7 @@ def test_check_file_meta_binary_contents():
)
@pytest.mark.skipif(
salt.utils.platform.is_windows(), reason="lsattr is not available on Windows"
)
@pytest.mark.skip_on_windows(reason="lsattr is not available on Windows")
def test_check_file_meta_no_lsattr():
"""
Ensure that we skip attribute comparison if lsattr(1) is not found
@ -134,8 +132,9 @@ def test_check_file_meta_no_lsattr():
assert result
@pytest.mark.skipif(
salt.utils.platform.is_windows() or salt.utils.platform.is_aix(),
@pytest.mark.skip_on_platforms(
windows=True,
aix=True,
reason="lsattr is not available on Windows and AIX",
)
def test_cmp_attrs_extents_flag():
@ -175,9 +174,7 @@ def test_cmp_attrs_extents_flag():
assert changes.removed is None
@pytest.mark.skipif(
salt.utils.platform.is_windows(), reason="SED is not available on Windows"
)
@pytest.mark.skip_on_windows(reason="SED is not available on Windows")
def test_sed_limit_escaped(sed_content, subdir):
with salt.utils.files.fopen(str(subdir / "tfile"), "w+") as tfile:
tfile.write(sed_content)

View file

@ -1,20 +1,17 @@
import logging
import os
import pytest
import salt.modules.aixpkg as aixpkg
import salt.modules.pkg_resource as pkg_resource
from salt.exceptions import CommandExecutionError
from tests.support.mock import MagicMock, patch
try:
import pytest
except ImportError:
pytest = None
log = logging.getLogger(__name__)
@pytest.fixture()
@pytest.fixture
def lslpp_out():
# Output from lslpp -Lc which contains Filesets and RPMs installed on system
# Package Name:Fileset:Level:State:PTF Id:Fix State:Type:Description:Destination Dir.:Uninstaller:Message Catalog:Message Set:Message Number:Parent:Automatic:EFIX Locked:Install Path:Build Date
@ -919,21 +916,21 @@ def test_version_with_valid_names():
(/bin/rpm)
State codes:
A -- Applied.
B -- Broken.
C -- Committed.
E -- EFIX Locked.
O -- Obsolete. (partially migrated to newer version)
? -- Inconsistent State...Run lppchk -v.
State codes:
A -- Applied.
B -- Broken.
C -- Committed.
E -- EFIX Locked.
O -- Obsolete. (partially migrated to newer version)
? -- Inconsistent State...Run lppchk -v.
Type codes:
F -- Installp Fileset
P -- Product
C -- Component
T -- Feature
R -- RPM Package
E -- Interim Fix
Type codes:
F -- Installp Fileset
P -- Product
C -- Component
T -- Feature
R -- RPM Package
E -- Interim Fix
"""
lslpp_bash_out = """ bash 5.1.4-2 C R The GNU Bourne Again shell
@ -941,21 +938,21 @@ Type codes:
(/bin/rpm)
State codes:
A -- Applied.
B -- Broken.
C -- Committed.
E -- EFIX Locked.
O -- Obsolete. (partially migrated to newer version)
? -- Inconsistent State...Run lppchk -v.
State codes:
A -- Applied.
B -- Broken.
C -- Committed.
E -- EFIX Locked.
O -- Obsolete. (partially migrated to newer version)
? -- Inconsistent State...Run lppchk -v.
Type codes:
F -- Installp Fileset
P -- Product
C -- Component
T -- Feature
R -- RPM Package
E -- Interim Fix
Type codes:
F -- Installp Fileset
P -- Product
C -- Component
T -- Feature
R -- RPM Package
E -- Interim Fix
"""
ver_chk = MagicMock(
@ -986,21 +983,21 @@ def test_version_with_invalid_names():
lslpp_mydog_out = """lslpp: Fileset mydog not installed.
State codes:
A -- Applied.
B -- Broken.
C -- Committed.
E -- EFIX Locked.
O -- Obsolete. (partially migrated to newer version)
? -- Inconsistent State...Run lppchk -v.
State codes:
A -- Applied.
B -- Broken.
C -- Committed.
E -- EFIX Locked.
O -- Obsolete. (partially migrated to newer version)
? -- Inconsistent State...Run lppchk -v.
Type codes:
F -- Installp Fileset
P -- Product
C -- Component
T -- Feature
R -- RPM Package
E -- Interim Fix
Type codes:
F -- Installp Fileset
P -- Product
C -- Component
T -- Feature
R -- RPM Package
E -- Interim Fix
"""
ver_chk = MagicMock(return_value={"retcode": 1, "stdout": lslpp_mydog_out})
@ -1186,8 +1183,8 @@ def test_install_fail_dnf_try_fileset():
"""
bos_net_fake_error = """AIX generic repository 12 kB/s | 2.6 kB 00:00
AIX noarch repository 12 kB/s | 2.5 kB 00:00
AIX 7.2 specific repository 12 kB/s | 2.5 kB 00:00
AIX noarch repository 12 kB/s | 2.5 kB 00:00
AIX 7.2 specific repository 12 kB/s | 2.5 kB 00:00
No match for argument: bos.net
Error: Unable to find a match: bos.net
"""
@ -1262,7 +1259,7 @@ FAILURES
discrepancies between the Table of Contents file (.toc) and the images that
reside in the directory.
fake_info
fake_info
<< End of Failure Section >>
@ -1270,7 +1267,7 @@ FAILURES
BUILDDATE Verification ...
+-----------------------------------------------------------------------------+
Verifying build dates...done
FILESET STATISTICS
FILESET STATISTICS
------------------
1 Selected to be installed, of which:
1 FAILED pre-installation verification
@ -1420,7 +1417,7 @@ SUCCESSES
BUILDDATE Verification ...
+-----------------------------------------------------------------------------+
Verifying build dates...done
FILESET STATISTICS
FILESET STATISTICS
------------------
1 Selected to be installed, of which:
1 Passed pre-installation verification
@ -1444,7 +1441,7 @@ installp: APPLYING software for:
All rights reserved.
US Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.
. . . . . << End of copyright notice for bos.adt >>. . . .
. . . . . << End of copyright notice for bos.adt >>. . . .
Successfully updated the Kernel Authorization Table.
Successfully updated the Kernel Role Table.
@ -1452,7 +1449,7 @@ Successfully updated the Kernel Command Table.
Successfully updated the Kernel Device Table.
Successfully updated the Kernel Object Domain Table.
Successfully updated the Kernel Domains Table.
Successfully updated the Kernel RBAC log level.
Successfully updated the Kernel RBAC log level.
Finished processing all filesets. (Total time: 1 secs).
+-----------------------------------------------------------------------------+
@ -1463,8 +1460,8 @@ Installation Summary
--------------------
Name Level Part Event Result
-------------------------------------------------------------------------------
bos.adt.insttools 7.2.2.0 USR APPLY SUCCESS
bos.adt.insttools 7.2.2.0 ROOT APPLY SUCCESS
bos.adt.insttools 7.2.2.0 USR APPLY SUCCESS
bos.adt.insttools 7.2.2.0 ROOT APPLY SUCCESS
"""
dnf_call = MagicMock(
side_effect=[fileset_pkg_name_lslpp_out_dict, {"retcode": 0, "stdout": ""}]

View file

@ -4,10 +4,7 @@
import pytest
import salt.modules.disk as disk
import salt.utils.path
import salt.utils.platform
from tests.support.mock import MagicMock, patch
from tests.support.unit import skipIf
@pytest.fixture
@ -270,10 +267,7 @@ def test_fat_format():
assert expected == args[0]
@skipIf(
not salt.utils.path.which("lsblk") and not salt.utils.path.which("df"),
"lsblk or df not found",
)
@pytest.mark.skip_if_binaries_missing("lsblk", "df", check_all=True)
def test_fstype():
"""
unit tests for disk.fstype

View file

@ -5,7 +5,6 @@ import pytest
import salt.modules.kmod as kmod
from salt.exceptions import CommandExecutionError
from tests.support.mock import MagicMock, patch
from tests.support.unit import skipIf
@pytest.fixture
@ -46,7 +45,9 @@ def test_lsmod():
assert expected == kmod.lsmod()
@skipIf(not os.path.isfile("/etc/modules"), "/etc/modules not present")
@pytest.mark.skipif(
not os.path.isfile("/etc/modules"), reason="/etc/modules not present"
)
def test_mod_list():
"""
Tests return a list of the loaded module names

View file

@ -68,9 +68,7 @@ def mock_info_ret():
}
@pytest.mark.skipif(
True, reason="Waiting on some clarifications from bug report #10594"
)
@pytest.mark.skip(reason="Waiting on some clarifications from bug report #10594")
def _test_flush_dscl_cache():
# TODO: Implement tests after clarifications come in
pass

View file

@ -734,8 +734,8 @@ def test_get_slave_status_bad_server():
assert rslt == []
@pytest.mark.skipif(
True, reason="MySQL module claims this function is not ready for production"
@pytest.mark.skip(
reason="MySQL module claims this function is not ready for production"
)
def test_free_slave():
pass

View file

@ -1,6 +1,8 @@
import logging
import os
import pytest
import salt.modules.cmdmod as cmdmod
import salt.modules.pkg_resource as pkg_resource
import salt.modules.rpm_lowpkg as rpm
@ -9,11 +11,6 @@ import salt.utils.platform
from salt.exceptions import CommandExecutionError, SaltInvocationError
from tests.support.mock import MagicMock, Mock, call, patch
try:
import pytest
except ImportError:
pytest = None
log = logging.getLogger(__name__)

View file

@ -18,13 +18,15 @@
import os
import pytest
from salt.modules.inspectlib.collector import Inspector
from tests.support.helpers import no_symlinks
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
@skipIf(no_symlinks(), "Git missing 'core.symlinks=true' config")
@pytest.mark.skipif(no_symlinks(), reason="Git missing 'core.symlinks=true' config")
class InspectorCollectorTestCase(TestCase):
"""
Test inspectlib:collector:Inspector

View file

@ -1,28 +1,30 @@
"""
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
"""
import pytest
import salt.modules.augeas_cfg as augeas_cfg
from salt.exceptions import SaltInvocationError
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# Make sure augeas python interface is installed
if augeas_cfg.HAS_AUGEAS:
from augeas import Augeas as _Augeas
@skipIf(augeas_cfg.HAS_AUGEAS is False, "python-augeas is required for this test case")
@pytest.mark.skipif(
augeas_cfg.HAS_AUGEAS is False,
reason="python-augeas is required for this test case",
)
class AugeasCfgTestCase(TestCase):
"""
Test cases for salt.modules.augeas_cfg
"""
# 'execute' function tests: 3
@skipIf(
True,
"Disabled pending https://github.com/hercules-team/python-augeas/issues/30",
@pytest.mark.skip(
"Disabled pending https://github.com/hercules-team/python-augeas/issues/30"
)
def test_execute(self):
"""

View file

@ -1,19 +1,19 @@
"""
Tests for salt.modules.boto3_elasticsearch
"""
import datetime
import random
import string
import textwrap
import pytest
import salt.loader
import salt.modules.boto3_elasticsearch as boto3_elasticsearch
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import boto3
@ -117,10 +117,10 @@ DOMAIN_RET = {
}
@skipIf(HAS_BOTO3 is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO3 is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
LooseVersion(boto3.__version__) < LooseVersion(REQUIRED_BOTO3_VERSION),
"The boto3 module must be greater or equal to version {}".format(
reason="The boto3 module must be greater or equal to version {}".format(
REQUIRED_BOTO3_VERSION
),
)

View file

@ -1,17 +1,17 @@
"""
Tests for salt.modules.boto3_route53
"""
import random
import string
import pytest
import salt.loader
import salt.modules.boto3_route53 as boto3_route53
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import boto3
@ -75,10 +75,10 @@ LIST_RESOURCE_RECORD_SETS_RETURN = {
}
@skipIf(HAS_BOTO3 is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO3 is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
LooseVersion(boto3.__version__) < LooseVersion(REQUIRED_BOTO3_VERSION),
"The boto3 module must be greater or equal to version {}".format(
reason="The boto3 module must be greater or equal to version {}".format(
REQUIRED_BOTO3_VERSION
),
)

View file

@ -3,13 +3,15 @@ import logging
import random
import string
import pytest
import salt.loader
import salt.loader.context
import salt.modules.boto_apigateway as boto_apigateway
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error,no-name-in-module
try:
@ -207,17 +209,16 @@ class BotoApiGatewayTestCaseMixin:
return False
# @pytest.mark.skip(reason='Skip these tests while investigating failures')
@skipIf(HAS_BOTO is False, "The boto3 module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto3 module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than or equal to version {}".format(
reason="The boto3 module must be greater than or equal to version {}".format(
required_boto3_version
),
)
@skipIf(
@pytest.mark.skipif(
_has_required_botocore() is False,
"The botocore module must be greater than or equal to version {}".format(
reason="The botocore module must be greater than or equal to version {}".format(
required_botocore_version
),
)

View file

@ -2,13 +2,15 @@ import logging
import random
import string
import pytest
import salt.config
import salt.loader
import salt.modules.boto_cloudtrail as boto_cloudtrail
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error,no-name-in-module,unused-import
try:
@ -84,10 +86,10 @@ if _has_required_boto():
)
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than or equal to version {}".format(
reason="The boto3 module must be greater than or equal to version {}".format(
required_boto3_version
),
)

View file

@ -2,12 +2,14 @@ import logging
import random
import string
import pytest
import salt.config
import salt.loader
import salt.modules.boto_cloudwatch_event as boto_cloudwatch_event
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error,no-name-in-module,unused-import
try:
@ -117,7 +119,7 @@ class BotoCloudWatchEventTestCaseMixin:
pass
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
class BotoCloudWatchEventTestCase(
BotoCloudWatchEventTestCaseBase, BotoCloudWatchEventTestCaseMixin
):

View file

@ -2,13 +2,15 @@ import logging
import random
import string
import pytest
import salt.config
import salt.loader
import salt.modules.boto_cognitoidentity as boto_cognitoidentity
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error,no-name-in-module
try:
@ -157,10 +159,10 @@ class BotoCognitoIdentityTestCaseMixin:
# @pytest.mark.skip(reason="Skip these tests while investigating failures")
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than or equal to version {}".format(
reason="The boto3 module must be greater than or equal to version {}".format(
required_boto3_version
),
)

View file

@ -3,12 +3,14 @@ import logging
import random
import string
import pytest
import salt.loader
import salt.modules.boto_elasticsearch_domain as boto_elasticsearch_domain
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error,no-name-in-module
try:
@ -117,10 +119,10 @@ class BotoElasticsearchDomainTestCaseMixin:
# @pytest.mark.skip(reason="Skip these tests while investigating failures")
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than or equal to version {}".format(
reason="The boto3 module must be greater than or equal to version {}".format(
required_boto3_version
),
)

View file

@ -3,6 +3,8 @@ import os.path
import sys
from copy import deepcopy
import pytest
import salt.config
import salt.loader
import salt.modules.boto_elb as boto_elb
@ -10,7 +12,7 @@ import salt.utils.versions
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error
try:
@ -103,11 +105,11 @@ def _has_required_moto():
return True
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_moto() is False,
"The moto module must be >= to {} for PY2 or {} for PY3.".format(
reason="The moto module must be >= to {} for PY2 or {} for PY3.".format(
required_moto, required_moto_py3
),
)
@ -250,9 +252,9 @@ class BotoElbTestCase(TestCase, LoaderModuleMockMixin):
@mock_ec2_deprecated
@mock_elb_deprecated
@skipIf(
@pytest.mark.skipif(
sys.version_info > (3, 6),
"Disabled for 3.7+ pending https://github.com/spulec/moto/issues/1706.",
reason="Disabled for 3.7+ pending https://github.com/spulec/moto/issues/1706.",
)
def test_get_elb_config(self):
"""

View file

@ -2,13 +2,15 @@ import logging
import random
import string
import pytest
import salt.config
import salt.loader
import salt.modules.boto_iot as boto_iot
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error,no-name-in-module,unused-import
try:
@ -112,10 +114,10 @@ if _has_required_boto():
)
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than or equal to version {}".format(
reason="The boto3 module must be greater than or equal to version {}".format(
required_boto3_version
),
)
@ -823,10 +825,10 @@ class BotoIoTPolicyTestCase(BotoIoTTestCaseBase, BotoIoTTestCaseMixin):
)
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than"
reason="The boto3 module must be greater than"
" or equal to version {}. The botocore"
" module must be greater than or equal to"
" version {}.".format(required_boto3_version, required_botocore_version),

View file

@ -14,7 +14,7 @@ from salt.exceptions import SaltInvocationError
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error,no-name-in-module
try:
@ -97,10 +97,10 @@ def _has_required_boto():
return True
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than or equal to version {}, "
reason="The boto3 module must be greater than or equal to version {}, "
"and botocore must be greater than or equal to {}".format(
required_boto3_version, required_botocore_version
),
@ -590,10 +590,10 @@ class BotoLambdaFunctionTestCase(BotoLambdaTestCaseBase, BotoLambdaTestCaseMixin
)
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than or equal to version {}".format(
reason="The boto3 module must be greater than or equal to version {}".format(
required_boto3_version
),
)
@ -767,10 +767,10 @@ class BotoLambdaAliasTestCase(BotoLambdaTestCaseBase, BotoLambdaTestCaseMixin):
)
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than or equal to version {}".format(
reason="The boto3 module must be greater than or equal to version {}".format(
required_boto3_version
),
)

View file

@ -3,7 +3,8 @@ import os.path
import sys
from collections import namedtuple
import pkg_resources # pylint: disable=3rd-party-module-not-gated
import pkg_resources
import pytest
import salt.config
import salt.loader
@ -11,7 +12,7 @@ import salt.utils.versions
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error
try:
@ -66,10 +67,10 @@ def _has_required_moto():
return True
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_moto() is False,
"The moto module must be >= to {}".format(required_moto),
reason="The moto module must be >= to {}".format(required_moto),
)
class BotoRoute53TestCase(TestCase, LoaderModuleMockMixin):
"""
@ -101,7 +102,7 @@ class BotoRoute53TestCase(TestCase, LoaderModuleMockMixin):
def tearDown(self):
del self.opts
@skipIf(sys.version_info >= (3, 10), "Fail with python 3.10")
@pytest.mark.skipif(sys.version_info >= (3, 10), reason="Fail with python 3.10")
@mock_route53_deprecated
def test_create_healthcheck(self):
"""

View file

@ -3,12 +3,14 @@ import random
import string
from copy import deepcopy
import pytest
import salt.loader
import salt.modules.boto_s3_bucket as boto_s3_bucket
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error,no-name-in-module,unused-import
try:
@ -149,10 +151,10 @@ if _has_required_boto():
}
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto3 module must be greater than or equal to version {}".format(
reason="The boto3 module must be greater than or equal to version {}".format(
required_boto3_version
),
)

View file

@ -4,17 +4,18 @@ import string
import sys
from copy import deepcopy
import pytest
import salt.config
import salt.loader
import salt.modules.boto_secgroup as boto_secgroup
# pylint: disable=import-error
from salt.utils.odict import OrderedDict
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=import-error
try:
import boto
@ -93,11 +94,11 @@ def _has_required_boto():
return True
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}".format(
reason="The boto module must be greater than or equal to version {}".format(
required_boto_version
),
)
@ -159,7 +160,7 @@ class BotoSecgroupTestCase(TestCase, LoaderModuleMockMixin):
]
self.assertEqual(boto_secgroup._split_rules(rules), split_rules)
@skipIf(sys.version_info >= (3, 10), "Fails with python 3.10")
@pytest.mark.skipif(sys.version_info >= (3, 10), reason="Fails with python 3.10")
@mock_ec2_deprecated
def test_create_ec2_classic(self):
"""
@ -204,7 +205,7 @@ class BotoSecgroupTestCase(TestCase, LoaderModuleMockMixin):
]
self.assertEqual(expected_create_result, secgroup_create_result)
@skipIf(sys.version_info >= (3, 10), "Fails with python 3.10")
@pytest.mark.skipif(sys.version_info >= (3, 10), reason="Fails with python 3.10")
@mock_ec2_deprecated
def test_get_group_id_ec2_classic(self):
"""
@ -225,8 +226,7 @@ class BotoSecgroupTestCase(TestCase, LoaderModuleMockMixin):
retrieved_group_id = boto_secgroup.get_group_id(group_name, **conn_parameters)
self.assertEqual(group_classic.id, retrieved_group_id)
@skipIf(
True,
@pytest.mark.skip(
"test skipped because moto does not yet support group"
" filters https://github.com/spulec/moto/issues/154",
)
@ -306,7 +306,7 @@ class BotoSecgroupTestCase(TestCase, LoaderModuleMockMixin):
)
self.assertEqual(expected_get_config_result, secgroup_get_config_result)
@skipIf(sys.version_info >= (3, 10), "Fails with python 3.10")
@pytest.mark.skipif(sys.version_info >= (3, 10), reason="Fails with python 3.10")
@mock_ec2_deprecated
def test_exists_true_name_classic(self):
"""
@ -372,7 +372,7 @@ class BotoSecgroupTestCase(TestCase, LoaderModuleMockMixin):
salt_exists_result = boto_secgroup.exists(group_id=group_id, **conn_parameters)
self.assertFalse(salt_exists_result)
@skipIf(sys.version_info >= (3, 10), "Fails with python 3.10")
@pytest.mark.skipif(sys.version_info >= (3, 10), reason="Fails with python 3.10")
@mock_ec2_deprecated
def test_delete_group_ec2_classic(self):
"""

View file

@ -20,7 +20,7 @@ from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=no-name-in-module,unused-import
try:
@ -135,17 +135,17 @@ def _has_required_moto():
return True
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}. Installed: {}".format(
reason="The boto module must be greater than or equal to version {}. Installed: {}".format(
required_boto_version, _get_boto_version() if HAS_BOTO else "None"
),
)
@skipIf(
@pytest.mark.skipif(
_has_required_moto() is False,
"The moto version must be >= to version {}. Installed: {}".format(
reason="The moto version must be >= to version {}. Installed: {}".format(
required_moto_version, _get_moto_version() if HAS_MOTO else "None"
),
)
@ -698,17 +698,17 @@ class BotoVpcTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
self.assertTrue(describe_vpc["vpc"]["is_default"])
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}. Installed: {}".format(
reason="The boto module must be greater than or equal to version {}. Installed: {}".format(
required_boto_version, _get_boto_version()
),
)
@skipIf(
@pytest.mark.skipif(
_has_required_moto() is False,
"The moto version must be >= to version {}".format(required_moto_version),
reason="The moto version must be >= to version {}".format(required_moto_version),
)
class BotoVpcSubnetsTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
@mock_ec2_deprecated
@ -1071,11 +1071,11 @@ class BotoVpcSubnetsTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
)
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}. Installed: {}".format(
reason="The boto module must be greater than or equal to version {}. Installed: {}".format(
required_boto_version, _get_boto_version()
),
)
@ -1139,11 +1139,11 @@ class BotoVpcInternetGatewayTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
self.assertTrue(igw_creation_result.get("created"))
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}. Installed: {}".format(
reason="The boto module must be greater than or equal to version {}. Installed: {}".format(
required_boto_version, _get_boto_version()
),
)
@ -1200,11 +1200,11 @@ class BotoVpcNatGatewayTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
self.assertTrue(ngw_creation_result.get("created"))
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}. Installed: {}".format(
reason="The boto module must be greater than or equal to version {}. Installed: {}".format(
required_boto_version, _get_boto_version()
),
)
@ -1252,17 +1252,17 @@ class BotoVpcCustomerGatewayTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
self.assertFalse(gw_exists_result["exists"])
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}. Installed: {}".format(
reason="The boto module must be greater than or equal to version {}. Installed: {}".format(
required_boto_version, _get_boto_version()
),
)
@skipIf(
@pytest.mark.skipif(
_has_required_moto() is False,
"The moto version must be >= to version {}".format(required_moto_version),
reason="The moto version must be >= to version {}".format(required_moto_version),
)
class BotoVpcDHCPOptionsTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
@mock_ec2_deprecated
@ -1480,11 +1480,11 @@ class BotoVpcDHCPOptionsTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
boto_vpc.dhcp_options_exists(**conn_parameters)
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}. Installed: {}".format(
reason="The boto module must be greater than or equal to version {}. Installed: {}".format(
required_boto_version, _get_boto_version()
),
)
@ -1930,11 +1930,11 @@ class BotoVpcNetworkACLTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
self.assertFalse(dhcp_disassociate_result)
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}. Installed: {}".format(
reason="The boto module must be greater than or equal to version {}. Installed: {}".format(
required_boto_version, _get_boto_version()
),
)
@ -2213,17 +2213,17 @@ class BotoVpcRouteTablesTestCase(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
self.assertFalse(route_replacing_result)
@skipIf(HAS_BOTO is False, "The boto module must be installed.")
@skipIf(HAS_MOTO is False, "The moto module must be installed.")
@skipIf(
@pytest.mark.skipif(HAS_BOTO is False, reason="The boto module must be installed.")
@pytest.mark.skipif(HAS_MOTO is False, reason="The moto module must be installed.")
@pytest.mark.skipif(
_has_required_boto() is False,
"The boto module must be greater than or equal to version {}. Installed: {}".format(
reason="The boto module must be greater than or equal to version {}. Installed: {}".format(
required_boto_version, _get_boto_version()
),
)
@skipIf(
@pytest.mark.skipif(
_has_required_moto() is False,
"The moto version must be >= to version {}".format(required_moto_version),
reason="The moto version must be >= to version {}".format(required_moto_version),
)
class BotoVpcPeeringConnectionsTest(BotoVpcTestCaseBase, BotoVpcTestCaseMixin):
@mock_ec2_deprecated

View file

@ -2,25 +2,19 @@
:codeauthor: Alan Somers <asomers@gmail.com>
"""
import re
import salt.utils.platform
import pytest
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import salt.modules.bsd_shadow as shadow
HAS_SHADOW = True
except ImportError:
HAS_SHADOW = False
shadow = pytest.importorskip("salt.modules.bsd_shadow")
# Although bsd_shadow runs on NetBSD and OpenBSD as well, the mocks are
# currently only designed for FreeBSD.
@skipIf(not salt.utils.platform.is_freebsd(), "minion is not FreeBSD")
@skipIf(not HAS_SHADOW, "shadow module is not available")
@pytest.mark.skip_unless_on_freebsd
class BSDShadowTest(TestCase, LoaderModuleMockMixin):
def setup_loader_modules(self):
return {

View file

@ -2,15 +2,15 @@
tests.unit.returners.cassandra_cql_test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""
import ssl
import pytest
import salt.modules.cassandra_cql as cassandra_cql
from salt.exceptions import CommandExecutionError
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import cassandra # pylint: disable=unused-import,wrong-import-position
@ -20,9 +20,9 @@ except ImportError:
HAS_CASSANDRA = False
@skipIf(
@pytest.mark.skipif(
not HAS_CASSANDRA,
"Please install the cassandra datastax driver to run cassandra_cql module unit"
reason="Please install the cassandra datastax driver to run cassandra_cql module unit"
" tests.",
)
class CassandraCQLReturnerTestCase(TestCase, LoaderModuleMockMixin):

View file

@ -1,12 +1,12 @@
"""
:codeauthor: Nicole Thomas <nicole@saltstack.com>
"""
import pytest
import salt.modules.dig as dig
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
_SPF_VALUES = {
"dig +short xmission.com TXT": {
@ -42,7 +42,7 @@ def _spf_side_effect(key, python_shell=False):
)
@skipIf(dig.__virtual__() is False, "Dig must be installed")
@pytest.mark.skipif(dig.__virtual__() is False, reason="Dig must be installed")
class DigTestCase(TestCase, LoaderModuleMockMixin):
def setup_loader_modules(self):
return {dig: {}}

View file

@ -1,10 +1,6 @@
"""
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
"""
import sys
import pytest
import salt.modules.djangomod as djangomod
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
@ -192,9 +188,6 @@ class DjangomodCliCommandTestCase(TestCase, LoaderModuleMockMixin):
runas=None,
)
@pytest.mark.skipif(
sys.version_info < (3, 6), reason="Py3.5 dictionaries are not ordered"
)
def test_django_admin_cli_createsuperuser(self):
mock = MagicMock()
with patch.dict(djangomod.__salt__, {"cmd.run": mock}):

View file

@ -2,10 +2,12 @@
:codeauthor: Lukas Raska <lukas@raska.me>
"""
import pytest
from salt.exceptions import CommandExecutionError, SaltInvocationError
from salt.modules import elasticsearch
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# Import elasticsearch exceptions
NO_ELASTIC = False
@ -15,7 +17,10 @@ except Exception: # pylint: disable=broad-except
NO_ELASTIC = True
@skipIf(NO_ELASTIC, "Install elasticsearch-py before running Elasticsearch unit tests.")
@pytest.mark.skipif(
NO_ELASTIC,
reason="Install elasticsearch-py before running Elasticsearch unit tests.",
)
class ElasticsearchTestCase(TestCase):
"""
Test cases for salt.modules.elasticsearch

View file

@ -3,12 +3,13 @@
"""
import os
import pytest
import yaml
import salt.modules.junos as junos
from tests.support.mixins import LoaderModuleMockMixin, XMLEqualityMixin
from tests.support.mock import ANY, MagicMock, PropertyMock, call, mock_open, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
from lxml import etree
@ -28,7 +29,9 @@ except ImportError:
HAS_JUNOS = False
@skipIf(not HAS_JUNOS, "The junos-eznc and jxmlease modules are required")
@pytest.mark.skipif(
not HAS_JUNOS, reason="The junos-eznc and jxmlease modules are required"
)
class Test_Junos_Module(TestCase, LoaderModuleMockMixin, XMLEqualityMixin):
def setup_loader_modules(self):
return {

View file

@ -6,9 +6,10 @@
"""
# pylint: disable=invalid-name,no-member
import re
import pytest
try:
# Import Salt Testing Libs
import salt.modules.kernelpkg_linux_apt as kernelpkg
@ -18,14 +19,14 @@ try:
from tests.support.kernelpkg import KernelPkgTestCase
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
HAS_MODULES = True
except ImportError:
HAS_MODULES = False
@skipIf(not HAS_MODULES, "Salt modules could not be loaded")
@pytest.mark.skipif(not HAS_MODULES, reason="Salt modules could not be loaded")
class AptKernelPkgTestCase(KernelPkgTestCase, TestCase, LoaderModuleMockMixin):
"""
Test cases for salt.modules.kernelpkg_linux_apt

View file

@ -6,25 +6,24 @@
"""
# pylint: disable=invalid-name,no-member
import pytest
from salt.exceptions import CommandExecutionError
from tests.support.kernelpkg import KernelPkgTestCase
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase
try:
# Import Salt Testing Libs
import salt.modules.kernelpkg_linux_yum as kernelpkg
import salt.modules.yumpkg as pkg
from salt.exceptions import CommandExecutionError
# Import Salt Libs
from tests.support.kernelpkg import KernelPkgTestCase
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
HAS_MODULES = True
except ImportError:
HAS_MODULES = False
@skipIf(not HAS_MODULES, "Salt modules could not be loaded")
@pytest.mark.skipif(not HAS_MODULES, reason="Salt modules could not be loaded")
class YumKernelPkgTestCase(KernelPkgTestCase, TestCase, LoaderModuleMockMixin):
"""
Test cases for salt.modules.kernelpkg_linux_yum

View file

@ -2,17 +2,17 @@
:codeauthor: Jochen Breuer <jbreuer@suse.de>
"""
# pylint: disable=no-value-for-parameter
import os
from contextlib import contextmanager
import pytest
import salt.utils.files
import salt.utils.platform
from salt.modules import kubernetesmod as kubernetes
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import Mock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
@contextmanager
@ -26,9 +26,9 @@ def mock_kubernetes_library():
yield mock_kubernetes_lib
@skipIf(
@pytest.mark.skipif(
not kubernetes.HAS_LIBS,
"Kubernetes client lib is not installed. Skipping test_kubernetes.py",
reason="Kubernetes client lib is not installed. Skipping test_kubernetes.py",
)
class KubernetesTestCase(TestCase, LoaderModuleMockMixin):
"""

View file

@ -1,15 +1,15 @@
"""
:codeauthor: :email:`Anthony Shaw <anthonyshaw@apache.org>`
"""
import logging
import pytest
import salt.modules.libcloud_compute as libcloud_compute
from salt.utils.versions import LooseVersion as _LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
REQUIRED_LIBCLOUD_VERSION = "2.0.0"
try:
@ -198,7 +198,7 @@ else:
MockComputeDriver = object
@skipIf(not HAS_LIBCLOUD, "No libcloud installed")
@pytest.mark.skipif(not HAS_LIBCLOUD, reason="No libcloud installed")
@patch(
"salt.modules.libcloud_compute._get_driver",
MagicMock(return_value=MockComputeDriver()),

View file

@ -1,12 +1,12 @@
"""
:codeauthor: Anthony Shaw <anthonyshaw@apache.org>
"""
import pytest
import salt.modules.libcloud_dns as libcloud_dns
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
class MockDNSDriver:
@ -18,7 +18,7 @@ def get_mock_driver():
return MockDNSDriver()
@skipIf(not libcloud_dns.HAS_LIBCLOUD, "No libcloud installed")
@pytest.mark.skipif(not libcloud_dns.HAS_LIBCLOUD, reason="No libcloud installed")
class LibcloudDnsModuleTestCase(TestCase, LoaderModuleMockMixin):
def setup_loader_modules(self):
module_globals = {

View file

@ -1,12 +1,12 @@
"""
:codeauthor: :email:`Anthony Shaw <anthonyshaw@apache.org>`
"""
import pytest
import salt.modules.libcloud_loadbalancer as libcloud_loadbalancer
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
from libcloud.loadbalancer.base import Algorithm, BaseDriver, LoadBalancer, Member
@ -85,7 +85,7 @@ def get_mock_driver():
return MockLBDriver()
@skipIf(not HAS_LIBCLOUD, "No libcloud package")
@pytest.mark.skipif(not HAS_LIBCLOUD, reason="No libcloud package")
@patch(
"salt.modules.libcloud_loadbalancer._get_driver",
MagicMock(return_value=MockLBDriver()),

View file

@ -1,12 +1,12 @@
"""
:codeauthor: :email:`Anthony Shaw <anthonyshaw@apache.org>`
"""
import pytest
import salt.modules.libcloud_storage as libcloud_storage
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
from libcloud.storage.base import BaseDriver, Container, Object
@ -61,7 +61,7 @@ def get_mock_driver():
return MockStorageDriver()
@skipIf(not HAS_LIBCLOUD, "No libcloud installed")
@pytest.mark.skipif(not HAS_LIBCLOUD, reason="No libcloud installed")
@patch(
"salt.modules.libcloud_storage._get_driver",
MagicMock(return_value=MockStorageDriver()),

View file

@ -1,21 +1,15 @@
"""
:codeauthor: Rupesh Tare <rupesht@saltstack.com>
"""
import pytest
import salt.modules.localemod as localemod
from salt.exceptions import CommandExecutionError
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, Mock, patch
from tests.support.unit import TestCase, skipIf
try:
import pytest
except ImportError as import_error:
pytest = None
from tests.support.unit import TestCase
@skipIf(not pytest, False)
class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
"""
Test cases for salt.modules.localemod

View file

@ -4,9 +4,11 @@ Tests for the nacl execution module
import sys
import pytest
import salt.utils.stringutils
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import libnacl.sealed # pylint: disable=unused-import
@ -19,8 +21,10 @@ except (ImportError, OSError, AttributeError):
HAS_LIBNACL = False
@skipIf(sys.version_info >= (3, 10), "Segfaults with python 3.10")
@skipIf(not HAS_LIBNACL, "skipping test_nacl, libnacl is unavailable")
@pytest.mark.skipif(sys.version_info >= (3, 10), reason="Segfaults with python 3.10")
@pytest.mark.skipif(
not HAS_LIBNACL, reason="skipping test_nacl, reason=libnacl is unavailable"
)
class NaclTest(TestCase, LoaderModuleMockMixin):
"""
Test the nacl runner

View file

@ -1,12 +1,12 @@
"""
:codeauthor: :email:`Zach Moody <zmoody@do.co>`
"""
import pytest
import salt.modules.netbox as netbox
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, call, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import pynetbox # pylint: disable=unused-import
@ -37,7 +37,7 @@ def mocked_clean_kwargs_get(**kwargs):
return {"name": "test"}
@skipIf(HAS_PYNETBOX is False, "pynetbox lib not installed")
@pytest.mark.skipif(HAS_PYNETBOX is False, reason="pynetbox lib not installed")
@patch("salt.modules.netbox._config", MagicMock())
class NetBoxTestCase(TestCase, LoaderModuleMockMixin):
def setup_loader_modules(self):

View file

@ -10,7 +10,7 @@ from salt._compat import ipaddress
from salt.exceptions import CommandExecutionError
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, mock_open, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
log = logging.getLogger(__name__)
@ -391,7 +391,6 @@ class NetworkTestCase(TestCase, LoaderModuleMockMixin):
{"comment": ret, "result": True},
)
@skipIf(not bool(ipaddress), "unable to import 'ipaddress'")
def test_is_private(self):
"""
Test for Check if the given IP address is a private address
@ -401,7 +400,6 @@ class NetworkTestCase(TestCase, LoaderModuleMockMixin):
with patch.object(ipaddress.IPv6Address, "is_private", return_value=True):
self.assertTrue(network.is_private("::1"))
@skipIf(not bool(ipaddress), "unable to import 'ipaddress'")
def test_is_loopback(self):
"""
Test for Check if the given IP address is a loopback address
@ -525,7 +523,7 @@ default via 192.168.0.1 dev wlp59s0 proto dhcp metric 600
192.240.157.233 via 10.16.119.224 dev gpd0
206.80.50.33 via 10.16.119.224 dev gpd0
209.34.94.97 via 10.16.119.224 dev gpd0
unreachable should ignore this
unreachable should ignore this
"""
mock_iproute_ipv6 = """::1 dev lo proto kernel metric 256 pref medium
2060:123:4069::10 dev enp5s0 proto kernel metric 100 pref medium
@ -592,13 +590,13 @@ multicast ff00::/8 dev docker0 table local proto kernel metric 256 linkdown pref
multicast ff00::/8 dev wlp3s0 table local proto kernel metric 256 pref medium
multicast ff00::/8 dev vpn0 table local proto kernel metric 256 pref medium
multicast ff00::/8 dev tun0 table local proto kernel metric 256 pref medium
unicast should ignore this
broadcast cast should ignore this
throw should ignore this
unreachable should ignore this
prohibit should ignore this
blackhole should ignore this
nat should ignore this
unicast should ignore this
broadcast cast should ignore this
throw should ignore this
unreachable should ignore this
prohibit should ignore this
blackhole should ignore this
nat should ignore this
"""
self.assertRaises(CommandExecutionError, network.default_route, "family")

View file

@ -1,15 +1,13 @@
import pytest
import salt.modules.nilrt_ip as nilrt_ip
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, mock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import pyiface
except ImportError:
pyiface = None
pytest.importorskip("pyiface")
@skipIf(not pyiface, "The python pyiface package is not installed")
class NilrtIPTestCase(TestCase, LoaderModuleMockMixin):
"""
TestCase for salt.modules.nilrt_ip module

View file

@ -2,6 +2,8 @@
:codeauthor: Mike Wiebe <@mikewiebe>
"""
import pytest
import salt.modules.cp as cp_module
import salt.modules.file as file_module
import salt.modules.nxos as nxos_module
@ -10,7 +12,7 @@ import salt.utils.pycrypto
from salt.exceptions import CommandExecutionError, SaltInvocationError
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, create_autospec, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
from tests.unit.modules.nxos.nxos_config import (
config_input_file,
config_result,
@ -105,9 +107,9 @@ class NxosTestCase(TestCase, LoaderModuleMockMixin):
result = nxos_module.check_password(username, password, encrypted=False)
self.assertFalse(result)
@skipIf(
@pytest.mark.skipif(
"sha256" not in salt.utils.pycrypto.methods,
"compatible crypt method for fake data not available",
reason="compatible crypt method for fake data not available",
)
def test_check_password_password_encrypted_false(self):

View file

@ -1,18 +1,16 @@
"""
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
"""
import sys
import pytest
import salt.modules.pam as pam
from tests.support.mock import mock_open, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
MOCK_FILE = "ok ok ignore "
@skipIf(sys.platform.startswith("openbsd"), "OpenBSD does not use PAM")
@pytest.mark.skip_on_openbsd(reason="OpenBSD does not use PAM")
class PamTestCase(TestCase):
"""
Test cases for salt.modules.pam

View file

@ -1,16 +1,16 @@
"""
:codeauthor: Mike Place <mp@saltstack.com>
"""
import time
from collections import namedtuple
import pytest
import salt.modules.ps as ps
import salt.utils.data
import salt.utils.psutil_compat as psutil
from tests.support.mock import MagicMock, Mock, call, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
HAS_PSUTIL_VERSION = False
@ -121,7 +121,7 @@ class PsTestCase(TestCase):
self.mocked_proc.name = "test_mock_proc"
self.mocked_proc.pid = 9999999999
@skipIf(not ps.PSUTIL2, "Only run for psutil 2.x")
@pytest.mark.skipif(not ps.PSUTIL2, reason="Only run for psutil 2.x")
def test__get_proc_cmdline(self):
cmdline = ["echo", "питон"]
ret = ps._get_proc_cmdline(DummyProcess(cmdline=cmdline))
@ -180,8 +180,9 @@ class PsTestCase(TestCase):
{"idle": 4, "nice": 2, "system": 3, "user": 1}, ps.cpu_times()
)
@skipIf(
HAS_PSUTIL_VERSION is False, "psutil 0.6.0 or greater is required for this test"
@pytest.mark.skipif(
HAS_PSUTIL_VERSION is False,
reason="psutil 0.6.0 or greater is required for this test",
)
def test_virtual_memory(self):
with patch(
@ -199,8 +200,9 @@ class PsTestCase(TestCase):
ps.virtual_memory(),
)
@skipIf(
HAS_PSUTIL_VERSION is False, "psutil 0.6.0 or greater is required for this test"
@pytest.mark.skipif(
HAS_PSUTIL_VERSION is False,
reason="psutil 0.6.0 or greater is required for this test",
)
def test_swap_memory(self):
with patch(
@ -340,7 +342,7 @@ class PsTestCase(TestCase):
assert len(result) == 1
## This is commented out pending discussion on https://github.com/saltstack/salt/commit/2e5c3162ef87cca8a2c7b12ade7c7e1b32028f0a
# @skipIf(not HAS_UTMP, "The utmp module must be installed to run test_get_users_utmp()")
# @pytest.mark.skipif(not HAS_UTMP, reason="The utmp module must be installed to run test_get_users_utmp()")
# @patch('salt.utils.psutil_compat.get_users', new=MagicMock(return_value=None)) # This will force the function to use utmp
# def test_get_users_utmp(self):
# pass

View file

@ -7,7 +7,7 @@ import salt.utils.win_reg
from salt.exceptions import CommandExecutionError
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import win32api
@ -23,7 +23,7 @@ UNICODE_VALUE = (
FAKE_KEY = "SOFTWARE\\{}".format(random_string("SaltTesting-", lowercase=False))
@skipIf(not HAS_WIN32, "Tests require win32 libraries")
@pytest.mark.skipif(not HAS_WIN32, reason="Tests require win32 libraries")
class WinFunctionsTestCase(TestCase, LoaderModuleMockMixin):
"""
Test cases for salt.modules.reg

View file

@ -4,9 +4,7 @@ Unit tests for the Snapper module
:codeauthor: Duncan Mac-Vicar P. <dmacvicar@suse.de>
:codeauthor: Pablo Suárez Hernández <psuarezhernandez@suse.de>
"""
import sys
import pytest
import salt.modules.snapper as snapper
import salt.utils.files
@ -15,7 +13,7 @@ from salt.exceptions import CommandExecutionError
from tests.support.helpers import with_tempfile
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, mock_open, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
DBUS_RET = {
"ListSnapshots": [
@ -185,7 +183,7 @@ MODULE_RET = {
}
@skipIf(sys.platform.startswith("win"), "Snapper not available on Windows")
@pytest.mark.skip_on_windows(reason="Snapper not available on Windows")
class SnapperTestCase(TestCase, LoaderModuleMockMixin):
def setup_loader_modules(self):
class DBusException(BaseException):
@ -585,7 +583,7 @@ class SnapperTestCase(TestCase, LoaderModuleMockMixin):
}
self.assertEqual(snapper.diff(), module_ret)
@skipIf(salt.utils.platform.is_linux() is False, "This is a linux only test")
@pytest.mark.skip_unless_on_linux(reason="This is a linux only test")
@with_tempfile()
def test__is_text_file(self, tempfile):
with salt.utils.files.fopen(tempfile, "w") as wfh:

View file

@ -1,14 +1,18 @@
import sys
import pytest
import salt.modules.pkg_resource as pkg_resource
import salt.modules.solarisipspkg as solarisips
import salt.utils.data
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
@skipIf(sys.platform != "solaris", "Skip when not running on Solaris")
@pytest.mark.skipif(
sys.platform != "solaris", reason="Skip when not running on Solaris"
)
class IpsTestCase(TestCase, LoaderModuleMockMixin):
"""
Test cases for salt.modules.solarisips

View file

@ -1,12 +1,12 @@
"""
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
"""
import pytest
import salt.modules.twilio_notify as twilio_notify
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
HAS_LIBS = False
try:
@ -88,7 +88,7 @@ class MockTwilioRestClient:
self.messages = MockMessages()
@skipIf(not HAS_LIBS, "twilio.rest is not available")
@pytest.mark.skipif(not HAS_LIBS, reason="twilio.rest is not available")
class TwilioNotifyTestCase(TestCase, LoaderModuleMockMixin):
"""
Test cases for salt.modules.twilio_notify

View file

@ -1,12 +1,12 @@
"""
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
"""
import pytest
import salt.modules.useradd as useradd
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import pwd
@ -47,7 +47,7 @@ class UserAddTestCase(TestCase, LoaderModuleMockMixin):
# 'getent' function tests: 2
@skipIf(HAS_PWD is False, "The pwd module is not available")
@pytest.mark.skipif(HAS_PWD is False, reason="The pwd module is not available")
def test_getent(self):
"""
Test if user.getent already have a value
@ -55,7 +55,7 @@ class UserAddTestCase(TestCase, LoaderModuleMockMixin):
with patch("salt.modules.useradd.__context__", MagicMock(return_value="Salt")):
self.assertTrue(useradd.getent())
@skipIf(HAS_PWD is False, "The pwd module is not available")
@pytest.mark.skipif(HAS_PWD is False, reason="The pwd module is not available")
def test_getent_user(self):
"""
Tests the return information on all users
@ -85,7 +85,7 @@ class UserAddTestCase(TestCase, LoaderModuleMockMixin):
# 'info' function tests: 1
@skipIf(HAS_PWD is False, "The pwd module is not available")
@pytest.mark.skipif(HAS_PWD is False, reason="The pwd module is not available")
def test_info(self):
"""
Test the user information
@ -121,7 +121,7 @@ class UserAddTestCase(TestCase, LoaderModuleMockMixin):
# 'list_users' function tests: 1
@skipIf(HAS_PWD is False, "The pwd module is not available")
@pytest.mark.skipif(HAS_PWD is False, reason="The pwd module is not available")
def test_list_users(self):
"""
Test if it returns a list of all users

View file

@ -4,6 +4,7 @@
Tests for functions in salt.modules.vsphere
"""
import pytest
import salt.modules.vsphere as vsphere
import salt.utils.args
@ -16,7 +17,7 @@ from salt.exceptions import (
)
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, Mock, call, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
from pyVmomi import vim, vmodl # pylint: disable=unused-import,no-name-in-module
@ -1488,7 +1489,7 @@ class TestVcenterConnectionTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(res, False)
@skipIf(not HAS_PYVMOMI, "The 'pyvmomi' library is missing")
@pytest.mark.skipif(not HAS_PYVMOMI, reason="The 'pyvmomi' library is missing")
class ListDatacentersViaProxyTestCase(TestCase, LoaderModuleMockMixin):
"""
Tests for salt.modules.vsphere.list_datacenters_via_proxy
@ -1579,7 +1580,7 @@ class ListDatacentersViaProxyTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(res, [{"name": "fake_dc1"}, {"name": "fake_dc2"}])
@skipIf(not HAS_PYVMOMI, "The 'pyvmomi' library is missing")
@pytest.mark.skipif(not HAS_PYVMOMI, reason="The 'pyvmomi' library is missing")
class CreateDatacenterTestCase(TestCase, LoaderModuleMockMixin):
"""
Tests for salt.modules.vsphere.create_datacenter
@ -1631,7 +1632,7 @@ class CreateDatacenterTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(res, {"create_datacenter": True})
@skipIf(not HAS_PYVMOMI, "The 'pyvmomi' library is missing")
@pytest.mark.skipif(not HAS_PYVMOMI, reason="The 'pyvmomi' library is missing")
class EraseDiskPartitionsTestCase(TestCase, LoaderModuleMockMixin):
"""
Tests for salt.modules.vsphere.erase_disk_partitions
@ -1737,7 +1738,7 @@ class EraseDiskPartitionsTestCase(TestCase, LoaderModuleMockMixin):
)
@skipIf(not HAS_PYVMOMI, "The 'pyvmomi' library is missing")
@pytest.mark.skipif(not HAS_PYVMOMI, reason="The 'pyvmomi' library is missing")
class RemoveDatastoreTestCase(TestCase, LoaderModuleMockMixin):
"""
Tests for salt.modules.vsphere.remove_datastore
@ -1838,7 +1839,7 @@ class RemoveDatastoreTestCase(TestCase, LoaderModuleMockMixin):
self.assertTrue(res)
@skipIf(not HAS_PYVMOMI, "The 'pyvmomi' library is missing")
@pytest.mark.skipif(not HAS_PYVMOMI, reason="The 'pyvmomi' library is missing")
class RemoveDiskgroupTestCase(TestCase, LoaderModuleMockMixin):
"""
Tests for salt.modules.vsphere.remove_diskgroup
@ -1944,8 +1945,10 @@ class RemoveDiskgroupTestCase(TestCase, LoaderModuleMockMixin):
self.assertTrue(res)
@skipIf(not HAS_PYVMOMI, "The 'pyvmomi' library is missing")
@skipIf(not vsphere.HAS_JSONSCHEMA, "The 'jsonschema' library is missing")
@pytest.mark.skipif(not HAS_PYVMOMI, reason="The 'pyvmomi' library is missing")
@pytest.mark.skipif(
not vsphere.HAS_JSONSCHEMA, reason="The 'jsonschema' library is missing"
)
class RemoveCapacityFromDiskgroupTestCase(TestCase, LoaderModuleMockMixin):
"""
Tests for salt.modules.vsphere.remove_capacity_from_diskgroup
@ -2160,7 +2163,7 @@ class RemoveCapacityFromDiskgroupTestCase(TestCase, LoaderModuleMockMixin):
self.assertTrue(res)
@skipIf(not HAS_PYVMOMI, "The 'pyvmomi' library is missing")
@pytest.mark.skipif(not HAS_PYVMOMI, reason="The 'pyvmomi' library is missing")
class ListClusterTestCase(TestCase, LoaderModuleMockMixin):
"""
Tests for salt.modules.vsphere.list_cluster
@ -2260,7 +2263,7 @@ class ListClusterTestCase(TestCase, LoaderModuleMockMixin):
self.mock__get_cluster_dict.assert_called_once_with("cl", self.mock_cl)
@skipIf(not HAS_PYVMOMI, "The 'pyvmomi' library is missing")
@pytest.mark.skipif(not HAS_PYVMOMI, reason="The 'pyvmomi' library is missing")
class RenameDatastoreTestCase(TestCase, LoaderModuleMockMixin):
"""
Tests for salt.modules.vsphere.rename_datastore
@ -2494,7 +2497,9 @@ class _GetProxyTargetTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(ret, self.mock_root)
@skipIf(not HAS_VSPHERE_SDK, "The 'vsphere-automation-sdk' library is missing")
@pytest.mark.skipif(
not HAS_VSPHERE_SDK, reason="The 'vsphere-automation-sdk' library is missing"
)
class TestVSphereTagging(TestCase, LoaderModuleMockMixin):
"""
Tests for:

View file

@ -2,12 +2,14 @@
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
"""
import pytest
import salt.modules.win_groupadd as win_groupadd
import salt.utils.win_functions
from tests.support.helpers import TstSuiteLoggingHandler
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, Mock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
# pylint: disable=unused-import
try:
@ -50,9 +52,9 @@ class MockGroupObj:
"""
@skipIf(
@pytest.mark.skipif(
not HAS_WIN_LIBS,
"win_groupadd unit tests can only be run if win32com, pythoncom, and pywintypes are"
reason="win_groupadd unit tests can only be run if win32com, pythoncom, and pywintypes are"
" installed",
)
class WinGroupTestCase(TestCase, LoaderModuleMockMixin):

View file

@ -8,7 +8,7 @@ import salt.modules.win_service as win_service
import salt.utils.path
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import pywintypes
@ -132,7 +132,7 @@ class WinServiceTestCase(TestCase, LoaderModuleMockMixin):
{"Patrick the Starfish": "patrick"},
)
@skipIf(not WINAPI, "win32serviceutil not available")
@pytest.mark.skipif(not WINAPI, reason="win32serviceutil not available")
@pytest.mark.slow_test
def test_start(self):
"""
@ -162,7 +162,7 @@ class WinServiceTestCase(TestCase, LoaderModuleMockMixin):
):
self.assertTrue(win_service.start("spongebob"))
@skipIf(not WINAPI, "pywintypes not available")
@pytest.mark.skipif(not WINAPI, reason="pywintypes not available")
def test_start_already_running(self):
"""
Test starting a service that is already running
@ -177,7 +177,7 @@ class WinServiceTestCase(TestCase, LoaderModuleMockMixin):
), patch.object(win_service, "_status_wait", mock_info):
self.assertTrue(win_service.start("spongebob"))
@skipIf(not WINAPI, "win32serviceutil not available")
@pytest.mark.skipif(not WINAPI, reason="win32serviceutil not available")
@pytest.mark.slow_test
def test_stop(self):
"""
@ -205,7 +205,7 @@ class WinServiceTestCase(TestCase, LoaderModuleMockMixin):
), patch.object(win_service, "status", mock_false):
self.assertTrue(win_service.stop("spongebob"))
@skipIf(not WINAPI, "pywintypes not available")
@pytest.mark.skipif(not WINAPI, reason="pywintypes not available")
def test_stop_not_running(self):
"""
Test stopping a service that is already stopped
@ -264,7 +264,7 @@ class WinServiceTestCase(TestCase, LoaderModuleMockMixin):
with patch.dict(win_service.__salt__, {"task.run": mock_true}):
self.assertTrue(win_service.execute_salt_restart_task())
@skipIf(not WINAPI, "win32serviceutil not available")
@pytest.mark.skipif(not WINAPI, reason="win32serviceutil not available")
def test_status(self):
"""
Test to return the status for a service

View file

@ -1,8 +1,10 @@
import sys
import pytest
import salt.modules.win_status as status
from tests.support.mock import ANY, Mock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import wmi
@ -10,7 +12,7 @@ except ImportError:
pass
@skipIf(status.HAS_WMI is False, "This test requires Windows")
@pytest.mark.skipif(status.HAS_WMI is False, reason="This test requires Windows")
class TestProcsBase(TestCase):
def __init__(self, *args, **kwargs):
TestCase.__init__(self, *args, **kwargs)
@ -82,9 +84,9 @@ class TestProcsAttributes(TestProcsBase):
self.assertEqual(self.proc["user_domain"], self._expected_domain)
@skipIf(
@pytest.mark.skipif(
sys.stdin.encoding != "UTF-8",
"UTF-8 encoding required for this test is not supported",
reason="UTF-8 encoding required for this test is not supported",
)
class TestProcsUnicodeAttributes(TestProcsBase):
def setUp(self):

View file

@ -12,7 +12,7 @@ import salt.utils.platform
import salt.utils.stringutils
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, Mock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import wmi
@ -123,7 +123,7 @@ class MockWMI_BIOS:
pass
@skipIf(not HAS_WMI, "WMI only available on Windows")
@pytest.mark.skipif(not HAS_WMI, reason="WMI only available on Windows")
@pytest.mark.skip_unless_on_windows
class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
"""
@ -178,7 +178,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
"""
self.assertEqual(win_system.init(3), "Not implemented on Windows at this time.")
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_poweroff(self):
"""
Test to poweroff a running system
@ -187,7 +189,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
with patch.object(win_system, "shutdown", mock):
self.assertEqual(win_system.poweroff(), "salt")
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_reboot(self):
"""
Test to reboot the system
@ -195,7 +199,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
with patch("salt.modules.win_system.shutdown", MagicMock(return_value=True)):
self.assertEqual(win_system.reboot(), True)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_reboot_with_timeout_in_minutes(self):
"""
Test to reboot the system with a timeout
@ -208,7 +214,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
timeout=5, in_seconds=False, reboot=True, only_on_pending_reboot=False
)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_reboot_with_timeout_in_seconds(self):
"""
Test to reboot the system with a timeout
@ -221,7 +229,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
timeout=5, in_seconds=True, reboot=True, only_on_pending_reboot=False
)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_reboot_with_wait(self):
"""
Test to reboot the system with a timeout and
@ -233,7 +243,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(win_system.reboot(wait_for_reboot=True), True)
time.assert_called_with(330)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_shutdown(self):
"""
Test to shutdown a running system
@ -243,7 +255,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
):
self.assertEqual(win_system.shutdown(), True)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_shutdown_hard(self):
"""
Test to shutdown a running system with no timeout or warning
@ -254,7 +268,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(win_system.shutdown_hard(), True)
shutdown.assert_called_with(timeout=0)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_set_computer_name(self):
"""
Test to set the Windows computer name
@ -280,7 +296,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
):
self.assertFalse(win_system.set_computer_name("salt"))
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_set_computer_desc(self):
"""
Test to set the Windows computer description
@ -300,7 +318,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
{"Computer Description": "Salt's comp"},
)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_get_computer_desc(self):
"""
Test to get the Windows computer description
@ -314,7 +334,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(win_system.get_computer_desc(), "salt description")
self.assertFalse(win_system.get_computer_desc())
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_join_domain(self):
"""
Test to join a computer to an Active Directory domain
@ -330,7 +352,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
{"Domain": "saltstack", "Restart": False},
)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_join_domain_already_joined(self):
"""
Test to join a computer to an Active Directory domain when it is
@ -347,7 +371,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
"Already joined to saltstack",
)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_unjoin_domain(self):
"""
Test unjoining a computer from an Active Directory domain
@ -363,7 +389,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
{"Workgroup": "WORKGROUP", "Restart": False},
)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_unjoin_domain_already_unjoined(self):
"""
Test unjoining a computer from an Active Directory domain
@ -390,7 +418,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
self.assertTrue(re.search(r"^\d{2}:\d{2} \w{2}$", win_tm))
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_set_system_time(self):
"""
Test to set system time
@ -409,7 +439,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
date = datetime.strftime(datetime.now(), "%m/%d/%Y")
self.assertEqual(win_system.get_system_date(), date)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_set_system_date(self):
"""
Test to set system date
@ -480,7 +512,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
self.assertEqual(ret, "MINION")
cmd_run_mock.assert_called_once_with(cmd="hostname")
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_get_system_info(self):
fields = [
"bios_caption",
@ -590,7 +624,9 @@ class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
self.assertIn(ret["chassis_bootup_state"], warning_states)
self.assertIn(ret["thermal_state"], warning_states)
@skipIf(not win_system.HAS_WIN32NET_MODS, "Missing win32 libraries")
@pytest.mark.skipif(
not win_system.HAS_WIN32NET_MODS, reason="Missing win32 libraries"
)
def test_get_system_info_no_number_of_enabled_core(self):
"""
Tests get_system_info when there is no `NumberOfEnabledCore` property in

View file

@ -14,18 +14,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import datetime
import os
import tempfile
import pytest
import salt.utils.files
import salt.utils.stringutils
from salt.modules import x509
from tests.support.helpers import dedent
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
try:
import M2Crypto # pylint: disable=unused-import
@ -122,7 +123,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
assert x509.log.trace.call_args[0][1] == list(subj.nid.keys())[0]
assert isinstance(x509.log.trace.call_args[0][2], TypeError)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_get_pem_entry(self):
"""
Test private function _parse_subject(subject) it handles a missing fields
@ -132,7 +135,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
ret = x509.get_pem_entry(ca_key)
self.assertEqual(ret, ca_key)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_get_private_key_size(self):
"""
Test private function _parse_subject(subject) it handles a missing fields
@ -142,7 +147,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
ret = x509.get_private_key_size(ca_key)
self.assertEqual(ret, 1024)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_create_key(self):
"""
Test that x509.create_key returns a private key
@ -151,7 +158,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
ret = x509.create_private_key(text=True, passphrase="super_secret_passphrase")
self.assertIn("BEGIN RSA PRIVATE KEY", ret)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_create_certificate(self):
"""
Test private function _parse_subject(subject) it handles a missing fields
@ -163,7 +172,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
ret = x509.create_certificate(**ca_kwargs)
self.assertIn("BEGIN CERTIFICATE", ret)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_create_certificate_with_not_after(self):
ca_key = default_values["ca_key"]
ca_kwargs = default_values["x509_args_ca"].copy()
@ -202,7 +213,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
# information in it.
self.assertIn(not_after_str, not_after_from_cert)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_create_certificate_with_not_before(self):
ca_key = default_values["ca_key"]
ca_kwargs = default_values.get("x509_args_ca").copy()
@ -240,7 +253,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
# information in it.
self.assertIn(not_before_str, not_before_from_cert)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_create_certificate_with_not_before_wrong_date(self):
ca_key = default_values["ca_key"]
ca_kwargs = default_values.get("x509_args_ca").copy()
@ -264,7 +279,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
cert_kwargs["not_before"] = not_before_str
x509.create_certificate(**cert_kwargs)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_create_certificate_with_not_after_wrong_date(self):
ca_key = default_values["ca_key"]
ca_kwargs = default_values.get("x509_args_ca").copy()
@ -288,7 +305,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
cert_kwargs["not_after"] = not_after_str
x509.create_certificate(**cert_kwargs)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_create_certificate_with_not_before_and_not_after(self):
ca_key = default_values["ca_key"]
ca_kwargs = default_values.get("x509_args_ca").copy()
@ -338,7 +357,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
self.assertIn(not_before_str, not_before_from_cert)
self.assertIn(not_after_str, not_after_from_cert)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_create_crl(self):
ca_key = default_values["ca_key"]
ca_kwargs = default_values.get("x509_args_ca").copy()
@ -371,7 +392,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
# Ensure that a CRL was actually created
self.assertIn("BEGIN X509 CRL", crl)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_revoke_certificate_with_crl(self):
ca_key = default_values["ca_key"]
ca_kwargs = default_values.get("x509_args_ca").copy()
@ -434,7 +457,9 @@ class X509TestCase(TestCase, LoaderModuleMockMixin):
# the revoked certificates
self.assertIn(serial_number, crl)
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_read_certificate(self):
"""
:return:
@ -467,7 +492,9 @@ class X509FipsTestCase(TestCase, LoaderModuleMockMixin):
def setup_loader_modules(self):
return {x509: {"__opts__": {"fips_mode": True}}}
@skipIf(not HAS_M2CRYPTO, "Skipping, M2Crypto is unavailable")
@pytest.mark.skipif(
not HAS_M2CRYPTO, reason="Skipping, reason=M2Crypto is unavailable"
)
def test_read_certificate(self):
"""
:return:

Some files were not shown because too many files have changed in this diff Show more