Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to ANSIBLE_COLLECTION_PATH #139

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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