Call coverage or pytest using python -m

This has the desired side effect to add the current directory to
`sys.path`
This commit is contained in:
Pedro Algarvio 2020-04-10 13:20:52 +01:00
parent a5b2b6c350
commit d3dbe0b39d
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -889,9 +889,11 @@ def _pytest(session, coverage, cmd_args):
try:
if coverage is True:
_run_with_coverage(session, "coverage", "run", "-m", "pytest", *cmd_args)
_run_with_coverage(
session, "python", "-m", "coverage", "run", "-m", "pytest", *cmd_args
)
else:
session.run("pytest", *cmd_args, env=env)
session.run("python", "-m", "pytest", *cmd_args, env=env)
except CommandFailed: # pylint: disable=try-except-raise
# Not rerunning failed tests for now
raise
@ -905,9 +907,11 @@ def _pytest(session, coverage, cmd_args):
cmd_args[idx] = parg.replace(".xml", "-rerun-failed.xml")
cmd_args.append("--lf")
if coverage is True:
_run_with_coverage(session, "coverage", "run", "-m", "pytest", *cmd_args)
_run_with_coverage(
session, "python", "-m", "coverage", "run", "-m", "pytest", *cmd_args
)
else:
session.run("pytest", *cmd_args, env=env)
session.run("python", "-m", "pytest", *cmd_args, env=env)
# pylint: enable=unreachable