# Template file for 'python3-pytest-cov'
pkgname=python3-pytest-cov
version=7.1.0
revision=1
build_style=python3-pep517
make_check_args="--deselect tests/test_pytest_cov.py::test_celery"
hostmakedepends="hatchling hatch-fancy-pypi-readme"
depends="python3-pytest python3-coverage python3-pluggy"
checkdepends="$depends python3-fields python3-process-tests
 python3-pytest-xdist python3-virtualenv"
short_desc="Pytest plugin for measuring coverage"
maintainer="Piotr Wójcik <chocimier@tlen.pl>"
license="MIT"
homepage="https://pytest-cov.readthedocs.io/en/latest/"
changelog="https://raw.githubusercontent.com/pytest-dev/pytest-cov/master/CHANGELOG.rst"
distfiles="${PYPI_SITE}/p/pytest-cov/pytest_cov-${version}.tar.gz"
checksum=30674f2b5f6351aa09702a9c8c364f6a01c27aae0c1366ae8016160d1efc56b2

do_check() {
	# Running via PYTHONPATH breaks a few tests so we use a venv
	local testdir="${wrksrc}/.xbps-testdir/$(date +%s)"
	python3 -m venv --system-site-packages --without-pip "${testdir}"

	local testpy="${testdir}/bin/python3"
	"${testpy}" -m installer dist/*.whl
	# see: https://github.com/pytest-dev/pytest-cov/issues/517
	PYTHONPATH="/${py3_sitelib}" PYTHONUSERBASE=/usr \
	PATH="${testdir}/bin:${PATH}" "${testpy}" -m pytest -n ${XBPS_MAKEJOBS} \
		${make_check_args} ${make_check_target}
}

post_install() {
	vlicense LICENSE
}
