Index: Mk/Uses/python.mk =================================================================== --- Mk/Uses/python.mk (revision 480287) +++ Mk/Uses/python.mk (working copy) @@ -115,6 +115,9 @@ # # noegginfo - Skip an egg-info entry from plist, if defined. # +# pytest - Test with pytest, can use PYTEST_ENV and PYTEST_ARGS +# variables. +# # PYTHON_CMD - Python's command line file name, including the # version number (used for dependencies). # default: ${PYTHONBASE}/bin/${PYTHON_VERSION} @@ -195,6 +198,14 @@ # unless you know what you do. # default: ${PYTHON_LIBDIR}/site-packages # +# PYTEST_ENV - Environment to run pytest in when +# USE_PYTHON=pytest is used. +# default: +# +# PYTEST_ARGS - Arguments that are supplied to pytest when +# USE_PYTHON=pytest is used. +# default: +# # There are PREFIX-clean variants of the PYTHON_*DIR variables above. # They are meant to be used by ports instead of the above variables, so the # ports respect ${PREFIX} (unless USE_PYTHON=pythonprefix is specified). @@ -597,6 +608,15 @@ . endfor .endif +.if defined(_PYTHON_FEATURE_PYTEST) +TEST_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}pytest>0:devel/py-pytest@${PY_FLAVOR} + +. if !target(do-test) +do-test: + @cd ${WRKSRC} && ${SETENV} ${PYTEST_ENV} ${PYTHON_CMD} -m pytest ${PYTEST_ARGS} +. endif +.endif + .if defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS) _RELSITELIBDIR= ${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;} _RELLIBDIR= ${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;}