Skip to content

Commit

Permalink
Adding test for resolved action
Browse files Browse the repository at this point in the history
There's also some black reformatting here
  • Loading branch information
matburt committed Feb 11, 2022
1 parent 907fb3f commit 0faa706
Show file tree
Hide file tree
Showing 2 changed files with 254 additions and 115 deletions.
36 changes: 32 additions & 4 deletions test/conftest.py
@@ -1,5 +1,6 @@
import pytest
from distutils.version import LooseVersion
import subprocess
import pkg_resources
import os

Expand All @@ -9,22 +10,49 @@ def mock_env_user(monkeypatch):
monkeypatch.setenv("ANSIBLE_DEVEL_WARNING", "False")


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def is_pre_ansible28():
try:
if LooseVersion(pkg_resources.get_distribution('ansible').version) < LooseVersion('2.8'):
if LooseVersion(
pkg_resources.get_distribution("ansible").version
) < LooseVersion("2.8"):
return True
except pkg_resources.DistributionNotFound:
# ansible-base (e.g. ansible 2.10 and beyond) is not accessible in this way
pass


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def is_pre_ansible212():
try:
base_version = (
subprocess.run(
"python -c 'import ansible; print(ansible.__version__)'",
capture_output=True,
shell=True,
)
.stdout.strip()
.decode()
)
if LooseVersion(base_version) < LooseVersion("2.12"):
return True
except pkg_resources.DistributionNotFound:
# ansible-base (e.g. ansible 2.10 and beyond) is not accessible in this way
pass


@pytest.fixture(scope="session")
def skipif_pre_ansible28(is_pre_ansible28):
if is_pre_ansible28:
pytest.skip("Valid only on Ansible 2.8+")


@pytest.fixture(scope="session")
def skipif_pre_ansible212(is_pre_ansible212):
if is_pre_ansible212:
pytest.skip("Valid only on Ansible 2.12+")


@pytest.fixture
def test_data_dir():
return os.path.join(os.path.dirname(__file__), 'data')
return os.path.join(os.path.dirname(__file__), "data")

0 comments on commit 0faa706

Please sign in to comment.