pytest_datafiles: new python recipe

This commit is contained in:
Joachim Mairböck
2024-08-25 17:52:41 +02:00
parent 675c81329a
commit ddbda0c7a9

View File

@@ -0,0 +1,69 @@
SUMMARY="Pytest plugin to create a tmpdir containing a preconfigured set of files"
DESCRIPTION="This plugin allows you to specify one or several files/directories that are copied \
to a temporary directory (tmp_path) before the execution of the test. This means the original \
files are not modified and every test runs on its own version of the same files.
Files/directories can be specified either as strings or as pathlib.Path objects.
To take advantage of the datafiles fixture in a test function, add datafiles as one of the test \
function parameters (per usual with pytest fixtures) and decorate the test function with \
@pytest.mark.datafiles(file1, file2, dir1, dir2, ...).
The datafiles variable in your test function is a pathlib.Path object (tmp_path) where the copied \
files are located."
HOMEPAGE="https://github.com/omarkohl/pytest-datafiles"
COPYRIGHT="2015 Omar Kohl"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/omarkohl/pytest-datafiles/releases/download/$portVersion/pytest_datafiles-$portVersion-py2.py3-none-any.whl#noarchive"
CHECKSUM_SHA256="2176e10d3f6e76f358925a897e21e2bcc5a0170b92fac4e66ed055eaa2ca6a22"
ARCHITECTURES="any"
DISABLE_SOURCE_PACKAGE="yes"
PROVIDES="
$portName = $portVersion
"
REQUIRES="
haiku
"
BUILD_REQUIRES="
haiku_devel
"
PYTHON_VERSIONS=(3.10)
for i in "${!PYTHON_VERSIONS[@]}"; do
pythonVersion=${PYTHON_VERSIONS[$i]}
pythonPackage=python${pythonVersion//.}
eval "PROVIDES_$pythonPackage=\"
${portName}_$pythonPackage = $portVersion
\"
REQUIRES_$pythonPackage=\"
haiku
cmd:python$pythonVersion
pytest_$pythonPackage
\""
BUILD_REQUIRES+="
installer_$pythonPackage
"
BUILD_PREREQUIRES+="
cmd:python$pythonVersion
"
done
INSTALL()
{
for i in "${!PYTHON_VERSIONS[@]}"; do
pythonVersion=${PYTHON_VERSIONS[$i]}
pythonPackage=python${pythonVersion//.}
python=python$pythonVersion
$python -m installer -p $prefix pytest_datafiles-$portVersion-py2.py3-none-any.whl
packageEntries $pythonPackage \
$prefix/lib/python*
done
}