From 1939f6c412fe3ef4c6860e79d97242aaff31610a Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 31 Oct 2018 19:49:48 -0700 Subject: [PATCH] Fix ansible-test invocation of pytest. --- test/runner/injector/injector.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/runner/injector/injector.py b/test/runner/injector/injector.py index 8fb1f1166d2..d9a66cb91dc 100755 --- a/test/runner/injector/injector.py +++ b/test/runner/injector/injector.py @@ -151,14 +151,22 @@ def injector(): :rtype: list[str], dict[str, str] """ command = os.path.basename(__file__) - executable = find_executable(command) + + run_as_python_module = ( + 'pytest', + ) + + if command in run_as_python_module: + executable_args = ['-m', command] + else: + executable_args = [find_executable(command)] if config.coverage_file: args, env = coverage_command() else: args, env = [config.python_interpreter], os.environ.copy() - args += [executable] + args += executable_args if command in ('ansible', 'ansible-playbook', 'ansible-pull'): if config.remote_interpreter is None: