From f76515228456259c85bdb74074b7ef4469286f9d Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Tue, 1 Aug 2023 07:02:55 -0700 Subject: [PATCH] Switch to ANSIBLE_COLLECTION_PATH (#139) --- src/pytest_ansible/plugin.py | 2 +- src/pytest_ansible/units.py | 8 ++++---- tests/unit/test_unit.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pytest_ansible/plugin.py b/src/pytest_ansible/plugin.py index de704958..b5e5b499 100644 --- a/src/pytest_ansible/plugin.py +++ b/src/pytest_ansible/plugin.py @@ -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") diff --git a/src/pytest_ansible/units.py b/src/pytest_ansible/units.py index 2f5f0d1d..1fec0f8f 100644 --- a/src/pytest_ansible/units.py +++ b/src/pytest_ansible/units.py @@ -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) @@ -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: diff --git a/tests/unit/test_unit.py b/tests/unit/test_unit.py index 3f712a6e..3501fb42 100644 --- a/tests/unit/test_unit.py +++ b/tests/unit/test_unit.py @@ -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)