mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Proper test skip
This commit is contained in:
parent
57d046a7db
commit
76343092f8
2 changed files with 14 additions and 15 deletions
|
@ -13,7 +13,6 @@ import pytest
|
|||
import salt.exceptions
|
||||
import salt.loader
|
||||
import salt.loader.lazy
|
||||
import tests.support.helpers
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -70,19 +69,16 @@ def test_named_loader_context_name_not_packed(tmp_path):
|
|||
opts = {
|
||||
"optimization_order": [0],
|
||||
}
|
||||
(tmp_path / "mymod.py").write_text(
|
||||
tests.support.helpers.dedent(
|
||||
"""
|
||||
contents = """
|
||||
from salt.loader.dunder import loader_context
|
||||
__not_packed__ = loader_context.named_context("__not_packed__")
|
||||
def foobar():
|
||||
return __not_packed__["not.packed"]()
|
||||
"""
|
||||
)
|
||||
)
|
||||
loader = salt.loader.LazyLoader([tmp_path], opts)
|
||||
with pytest.raises(
|
||||
salt.exceptions.LoaderError,
|
||||
match="LazyLoader does not have a packed value for: __not_packed__",
|
||||
):
|
||||
loader["mymod.foobar"]()
|
||||
with pytest.helpers.temp_file("mymod.py", contents, directory=tmp_path):
|
||||
loader = salt.loader.LazyLoader([tmp_path], opts)
|
||||
with pytest.raises(
|
||||
salt.exceptions.LoaderError,
|
||||
match="LazyLoader does not have a packed value for: __not_packed__",
|
||||
):
|
||||
loader["mymod.foobar"]()
|
||||
|
|
|
@ -2,7 +2,6 @@ import pytest
|
|||
|
||||
import salt.loader
|
||||
import salt.loader.lazy
|
||||
|
||||
import salt.modules.boto_vpc
|
||||
import salt.modules.virt
|
||||
|
||||
|
@ -13,7 +12,9 @@ def minion_mods(minion_opts):
|
|||
return salt.loader.minion_mods(minion_opts, utils=utils)
|
||||
|
||||
|
||||
@pytest.mark.skipIf(not salt.modules.boto_vpc.HAS_BOTO, "boto must be installed.")
|
||||
@pytest.mark.skipif(
|
||||
not salt.modules.boto_vpc.HAS_BOTO, reason="boto must be installed."
|
||||
)
|
||||
def test_load_boto_vpc(minion_mods):
|
||||
func = None
|
||||
try:
|
||||
|
@ -24,7 +25,9 @@ def test_load_boto_vpc(minion_mods):
|
|||
assert isinstance(func, salt.loader.lazy.LoadedFunc)
|
||||
|
||||
|
||||
@pytest.mark.skipIf(not salt.modules.virt.HAS_LIBVIRT, "libvirt-python must be installed.")
|
||||
@pytest.mark.skipif(
|
||||
not salt.modules.virt.HAS_LIBVIRT, reason="libvirt-python must be installed."
|
||||
)
|
||||
def test_load_virt(minion_mods):
|
||||
func = None
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue