SUMMARY="A Python module which extends unittest to make testing easier"
DESCRIPTION="nose extends the test loading and running features of unittest, \
making it easier to write, find and run tests.

By default, nose will run tests in files or directories under the current \
working directory whose names include \"test\" or \"Test\" at a word boundary \
(like \"test_this\" or \"functional_test\" or \"TestClass\" but not \
\"libtest\"). Test output is similar to that of unittest, but also includes \
captured stdout output from failing tests, for easy print-style debugging.

These features, and many more, are customizable through the use of plugins. \
Plugins included with nose provide support for doctest, code coverage, and \
profiling, flexible attribute-based test selection, output capture and more."
HOMEPAGE="https://readthedocs.io/docs/nose/
	https://pypi.python.org/pypi/nose/
	https://github.com/nose-devs/nose"
COPYRIGHT="2008-2010 anatoly techtonik"
LICENSE="GNU LGPL v2.1"
REVISION="3"
SOURCE_URI="https://pypi.io/packages/source/n/nose/nose-$portVersion.tar.gz"
CHECKSUM_SHA256="f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98"

ARCHITECTURES="any"

PROVIDES="
	nose = $portVersion
	"
REQUIRES="
	haiku
	"
BUILD_REQUIRES="
	haiku_devel
	"

PYTHON_PACKAGES=(python python3 python38 python39)
PYTHON_VERSIONS=(2.7 3.7 3.8 3.9)
for i in "${!PYTHON_PACKAGES[@]}"; do
	pythonPackage=${PYTHON_PACKAGES[i]}
	pythonVersion=${PYTHON_VERSIONS[i]}
	eval "PROVIDES_$pythonPackage=\"
		nose_$pythonPackage = $portVersion
		cmd:nosetests_$pythonVersion
		\""
	eval "REQUIRES_$pythonPackage=\"
		haiku
		cmd:python$pythonVersion
		\""
BUILD_REQUIRES="$BUILD_REQUIRES
	setuptools_$pythonPackage
	six_$pythonPackage
	"
BUILD_PREREQUIRES="$BUILD_PREREQUIRES
	cmd:python$pythonVersion"
done

PATCH()
{
	sed -i "s|man/|$relativeManDir/|" setup.py
}

BUILD()
{
	for i in "${!PYTHON_PACKAGES[@]}"; do
		pythonPackage=${PYTHON_PACKAGES[i]}
		pythonVersion=${PYTHON_VERSIONS[i]}

		rm -rf "$sourceDir"-$pythonPackage
		cp -a "$sourceDir" "$sourceDir"-$pythonPackage
		cd "$sourceDir"-$pythonPackage

		python=python$pythonVersion
		$python setup.py build
	done
}

INSTALL()
{
	for i in "${!PYTHON_PACKAGES[@]}"; do
		pythonPackage=${PYTHON_PACKAGES[i]}
		pythonVersion=${PYTHON_VERSIONS[i]}

		cd "$sourceDir"-$pythonPackage

		python=python$pythonVersion
		installLocation=$prefix/lib/$python/vendor-packages
		export PYTHONPATH=$installLocation
		mkdir -p "$installLocation"
		$python setup.py install \
			--root=/ --prefix="$prefix" --skip-build

		rm $binDir/nosetests
		packageEntries $pythonPackage \
			"$binDir" \
			"$prefix"/lib/$python
	done

	cd "$sourceDir"
	mkdir -p "$docDir"
	cp -rt "$docDir" \
		README.txt CHANGELOG NEWS* doc/*
	rm -f "$docDir"/Makefile
}

TEST()
{
	for i in "${!PYTHON_PACKAGES[@]}"; do
		pythonPackage=${PYTHON_PACKAGES[i]}
		pythonVersion=${PYTHON_VERSIONS[$i]}

		cd "$sourceDir"-$pythonPackage

		python=python$pythonVersion
		$python setup.py test || echo Tests failed with $python && true
	done
}
