Skip to content

Commit

Permalink
Improve: Convert py.test calls to pytest (Makefile, tox.ini)
Browse files Browse the repository at this point in the history
- Long time coming: `pytest` was introduced as recommended
  entry point on 2016-06-21:

    pytest-dev/pytest#1629
  • Loading branch information
landonb committed May 20, 2023
1 parent b2d75e8 commit 0e90acf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ isort: venvforce
# ^^^^^ Start pdb on error or KeyboardInterrupt

test: venvforce
py.test $(TEST_ARGS) tests/
pytest $(TEST_ARGS) tests/
.PHONY: test

test-all: venvforce
Expand All @@ -254,7 +254,7 @@ test-debug: test-local quickfix
# SAVVY: By default, a pipeline returns the exit code of the final command,
# so if you pipe to `tee`, the pipeline always returns true, e.g.,
#
# py.test ... | tee ...
# pytest ... | tee ...
#
# will always return true, regardless of py.text failing or not.
#
Expand All @@ -265,7 +265,7 @@ test-debug: test-local quickfix
# ...
# test-local:
# set -o pipefail
# py.test ... | tee ...
# pytest ... | tee ...
#
# But then pipefail (and bash) apply to all targets that shell-out.
#
Expand All @@ -279,19 +279,19 @@ test-debug: test-local quickfix
# ...
# test-local:
# set -o pipefail; \
# py.test ... | tee ...
# pytest ... | tee ...
#
# But, as mentioned above, then we're applying Bash to all shell-outs,
# and this author would prefer POSIX-compatible shell code when possible.
test-local: venvforce
py.test $(TEST_ARGS) tests/ | tee .make.out
# Express the exit code of py.test, not the tee.
pytest $(TEST_ARGS) tests/ | tee .make.out
# Express the exit code of pytest, not the tee.
exit ${PIPESTATUS[0]}
.PHONY: test-local

# ALTLY: Use `TEST_ARGS=-x make test`
test-one: venvforce
py.test $(TEST_ARGS) -x tests/
pytest $(TEST_ARGS) -x tests/
.PHONY: test-one

quickfix:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[build-system]
requires = ["setuptools", "wheel"]

# py.test options
# ===============
# pytest options
# ==============
#
# - pytest settings can be set in any of these files:
#
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ commands =
# Remove XML so codecov regenerates it.
/bin/rm -f coverage.xml
# Run tests and generate coverage.
py.test --cov=./easy_as_pypi tests/
pytest --cov=./easy_as_pypi tests/
# Upload coverage results to codecov.io.
codecov

Expand Down

0 comments on commit 0e90acf

Please sign in to comment.