diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index d88091506..89acb6c65 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -51,7 +51,7 @@ jobs: matrix: ${{ fromJson(needs.pre.outputs.matrix) }} env: - PYTEST_REQPASS: 449 + PYTEST_REQPASS: 450 steps: - uses: actions/checkout@v3 with: diff --git a/src/molecule/test/a_unit/verifier/test_testinfra.py b/src/molecule/test/a_unit/verifier/test_testinfra.py index 379353e2f..640790a4c 100644 --- a/src/molecule/test/a_unit/verifier/test_testinfra.py +++ b/src/molecule/test/a_unit/verifier/test_testinfra.py @@ -274,6 +274,18 @@ def test_execute_bakes(patched_run_command, _patched_testinfra_get_tests, _insta assert patched_run_command.call_count == 1 +@pytest.mark.parametrize("config_instance", ["_verifier_section_data"], indirect=True) +def test_execute_bakes_env( + patched_run_command, + _patched_testinfra_get_tests, + inventory_directory, + _instance, +): + _instance.execute() + + assert patched_run_command.call_args[1]["env"]["FOO"] == "bar" + + def test_testinfra_executes_catches_and_exits_return_code( patched_run_command, _patched_testinfra_get_tests, diff --git a/src/molecule/verifier/testinfra.py b/src/molecule/verifier/testinfra.py index ce3819c44..0ce25569b 100644 --- a/src/molecule/verifier/testinfra.py +++ b/src/molecule/verifier/testinfra.py @@ -180,7 +180,12 @@ def execute(self, action_args=None): msg = f"Executing Testinfra tests found in {self.directory}/..." LOG.info(msg) - result = util.run_command(self._testinfra_command, debug=self._config.debug) + result = util.run_command( + self._testinfra_command, + env=self.env, + debug=self._config.debug, + cwd=self._config.scenario.directory, + ) if result.returncode == 0: msg = "Verifier completed successfully." LOG.info(msg)