diff --git a/Uses/pytest.mk b/Uses/pytest.mk new file mode 100644 --- /dev/null +++ b/Uses/pytest.mk @@ -0,0 +1,69 @@ +# handle testing with pytest +# +# Feature: pytest +# Usage: USES=pytest[:4] +# +# It implies USES=python:test automatically if no USES=python has been +# specified yet +# +# It provides the following additional variables to set by the ports: +# +# PYTEST_ARGS additional args to pytest (defaults to empty). +# PYTEST_IGNORED_TESTS lists of `pytest -k` patterns of tests to ignore +# (defaults to empty). For tests which are not +# expected to pass, such as ones requiring a database +# access. +# PYTEST_BROKEN_TESTS lists of `pytest -k` patterns of tests to ignore +# (defaults to empty). For broken tests which require +# fixing. +# +# The following variables may be set by the user: +# +# PYTEST_ENABLE_IGNORED_TESTS enable tests which are otherwise ignored by +# PYTEST_IGNORED_TESTS. +# PYTEST_ENABLE_BROKEN_TESTS enable tests which are otherwise ignored by +# PYTEST_BROKEN_TESTS. +# PYTEST_ENABLE_ALL_TESTS enable tests which are otherwise ignored by +# PYTEST_IGNORED_TESTS and PYTEST_BROKEN_TESTS. +# +# MAINTAINER: amdmi3@FreeBSD.org + +.if !defined(_INCLUDE_USES_PYTEST_MK) +_INCLUDE_USES_PYTEST_MK= yes + +. if !${USES:Mpython*} +python_ARGS= test +.include "${USESDIR}/python.mk" +. endif + +. if empty(pytest_ARGS) +TEST_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}pytest>=0:devel/py-pytest@${PY_FLAVOR} +. elif ${pytest_ARGS} == "4" +TEST_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}pytest4>=0:devel/py-pytest4@${PY_FLAVOR} +. else +IGNORE= Incorrect 'USES+=pytest:${pytest_ARGS}' expecting 'USES+=pytest[:4]' +. endif + +PYTEST_IGNORED_TESTS?= # empty +PYTEST_BROKEN_TESTS?= # empty +PYTEST_ARGS?= # empty + +_PYTEST_ALL_IGNORED_TESTS?= # empty +. if !defined(PYTEST_ENABLE_IGNORED_TESTS) && !defined(PYTEST_ENABLE_ALL_TESTS) +_PYTEST_ALL_IGNORED_TESTS+= ${PYTEST_IGNORED_TESTS} +. endif +. if !defined(PYTEST_ENABLE_BROKEN_TESTS) && !defined(PYTEST_ENABLE_ALL_TESTS) +_PYTEST_ALL_IGNORED_TESTS+= ${PYTEST_BROKEN_TESTS} +. endif + +_PYTEST_FILTER_EXPRESSION= ${_PYTEST_ALL_IGNORED_TESTS:C/^(.)/and not \1/:tW:C/^and //} + +. if !target(do-test) +do-test: + @cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} ${PYTHON_CMD} -m pytest \ + -v -rs \ + -k '${_PYTEST_FILTER_EXPRESSION}' + ${PYTEST_ARGS} +. endif + +.endif diff --git a/ftp/py-aioftp/Makefile b/py-aioftp/Makefile --- a/ftp/py-aioftp/Makefile +++ b/py-aioftp/Makefile @@ -10,19 +10,16 @@ LICENSE= APACHE20 LICENSE_FILE= ${WRKSRC}/license.txt -TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest4>0:devel/py-pytest4@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}pytest4-asyncio>=0:devel/py-pytest4-asyncio@${PY_FLAVOR} \ +TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest4-asyncio>=0:devel/py-pytest4-asyncio@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}pytest4-cov>=0:devel/py-pytest4-cov@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}trustme>=0:security/py-trustme@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}async_timeout>0:devel/py-async_timeout@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}siosocks>0:net/py-siosocks@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}idna>0:dns/py-idna@${PY_FLAVOR} -USES= python:3.7+ +USES= python:3.7+ pytest:4 USE_PYTHON= autoplist distutils NO_ARCH= yes - -do-test: - @cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} ${PYTHON_CMD} -m pytest -v -rs +PYTEST_BROKEN_TESTS= test_pasv_connection_pasv_forced_response_address .include diff --git a/devel/py-asttokens/Makefile b/py-asttokens/Makefile --- a/devel/py-asttokens/Makefile +++ b/py-asttokens/Makefile @@ -12,14 +12,15 @@ BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}setuptools_scm>=0:devel/py-setuptools_scm@${PY_FLAVOR} RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}six>0:devel/py-six@${PY_FLAVOR} -TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest>=0:devel/py-pytest@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}astroid>0:devel/py-astroid@${PY_FLAVOR} +TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}astroid>0:devel/py-astroid@${PY_FLAVOR} -USES= python:3.6+ +USES= python:3.6+ pytest USE_PYTHON= autoplist distutils NO_ARCH= yes - -do-test: - @cd ${WRKSRC} && ${PYTHON_CMD} ${PYDISTUTILS_SETUP} test +PYTEST_BROKEN_TESTS= test_assignment_expressions test_async_def test_decorators \ + test_fixture10 test_fixture11 test_fixture13 test_fixture3 \ + test_fixture4 test_fixture5 test_fixture7 test_fixture8 \ + test_fixture9 test_fstrings test_mark_tokens_simple \ + test_print_function test_splat test_sys_modules test_tuples .include diff --git a/www/py-multidict/Makefile b/py-multidict/Makefile --- a/www/py-multidict/Makefile +++ b/py-multidict/Makefile @@ -10,17 +10,13 @@ LICENSE= APACHE20 LICENSE_FILE= ${WRKSRC}/LICENSE -TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest>=0:devel/py-pytest@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}pytest-runner>=0:devel/py-pytest-runner@${PY_FLAVOR} \ +TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest-runner>=0:devel/py-pytest-runner@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}pytest-cov>=0:devel/py-pytest-cov@${PY_FLAVOR} -USES= python:3.7+ +USES= python:3.7+ pytest USE_PYTHON= autoplist cython distutils post-install: @${STRIP_CMD} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/multidict/*.so -do-test: - @cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} ${PYTHON_CMD} -m pytest -v -rs -o addopts= - .include