Skip to content

Commit

Permalink
Call pytest using "python -m pytest"
Browse files Browse the repository at this point in the history
Directly calling "pytest" sometimes breaks tests on "pypy", such as pypa#234, because the actual current code is untested.

As explained from pypy website <https://docs.pytest.org/en/latest/usage.html>:

> ["python -m pytest"] is almost equivalent to invoking the command line
> script pytest [...] directly, except that calling via python will also
> add the current directory to sys.path.

Note that, unlike tests for pypy, the pytest script is not directly invoked in tests for other
Python interpreters.
  • Loading branch information
xuhdev committed Jan 28, 2020
1 parent 54d57d7 commit 78c167e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def coverage(*args):
coverage("report", "-m", "--fail-under", "100")
else:
# Don't do coverage tracking for PyPy, since it's SLOW.
session.run("pytest", "--capture=no", "--strict", *session.posargs)
session.run(
"python", "-m", "pytest", "--capture=no", "--strict", *session.posargs
)


@nox.session(python="3.8")
Expand Down

0 comments on commit 78c167e

Please sign in to comment.