Skip to content

Commit

Permalink
Switch to ANSIBLE_COLLECTION_PATH (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock committed Aug 1, 2023
1 parent 2a7e248 commit f765152
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pytest_ansible/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def pytest_addoption(parser):
"--ansible-unit-inject-only",
action="store_true",
default=False,
help="Enable support for ansible collection unit tests by only injecting exisiting ANSIBLE_COLLECTIONS_PATHS.",
help="Enable support for ansible collection unit tests by only injecting exisiting ANSIBLE_COLLECTIONS_PATH.",
)
# Add github marker to --help
parser.addini("ansible", "Ansible integration", "args")
Expand Down
8 changes: 4 additions & 4 deletions src/pytest_ansible/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def inject(start_path: Path) -> None:

logger.info("Collections dir: %s", collections_dir)

# TODO: Make this a configuration option, check COLLECTIONS_PATHS
# TODO: Make this a configuration option, check COLLECTIONS_PATH
# Add the user location for any dependencies
paths = [str(collections_dir), "~/.ansible/collections"]
logger.info("Paths: %s", paths)
Expand All @@ -121,12 +121,12 @@ def inject(start_path: Path) -> None:
# Set the environment variable as courtesy for integration tests
env_paths = os.pathsep.join(paths)
logger.info("Setting ANSIBLE_COLLECTIONS_PATH to %s", env_paths)
os.environ["ANSIBLE_COLLECTIONS_PATHS"] = env_paths
os.environ["ANSIBLE_COLLECTIONS_PATH"] = env_paths


def inject_only() -> None:
"""Inject the current ANSIBLE_COLLECTIONS_PATHS."""
env_paths = os.environ.get("ANSIBLE_COLLECTIONS_PATHS", "")
"""Inject the current ANSIBLE_COLLECTIONS_PATH."""
env_paths = os.environ.get("ANSIBLE_COLLECTIONS_PATH", "")
path_list = env_paths.split(os.pathsep)
for path in path_list:
if path:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_inject_only(
:param caplog: The pytest caplog fixture
"""
caplog.set_level(logging.DEBUG)
monkeypatch.setenv("ANSIBLE_COLLECTIONS_PATHS", str(tmp_path / "collections"))
monkeypatch.setenv("ANSIBLE_COLLECTIONS_PATH", str(tmp_path / "collections"))

(tmp_path / "collections" / "ansible_collections").mkdir(parents=True)

Expand Down

0 comments on commit f765152

Please sign in to comment.