summaryrefslogtreecommitdiff
blob: 44b2230d9389bac034910f0d223244b13283c084 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-python/logilab-common/logilab-common-0.50.1.ebuild,v 1.1 2010/04/28 17:18:38 arfrever Exp $

EAPI="3"
PYTHON_DEPEND="2"
SUPPORT_PYTHON_ABIS="1"

inherit distutils eutils

DESCRIPTION="Useful miscellaneous modules used by Logilab projects"
HOMEPAGE="http://www.logilab.org/projects/common/ http://pypi.python.org/pypi/logilab-common"
SRC_URI="ftp://ftp.logilab.org/pub/common/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~ia64 ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~ia64-linux ~x86-linux ~x64-macos ~x86-macos"
IUSE="test"

# Tests using dev-python/psycopg are skipped when dev-python/psycopg isn't installed.
DEPEND="test? (
		dev-python/egenix-mx-base
		!dev-python/psycopg[-mxdatetime]
	)"
RDEPEND=""
RESTRICT_PYTHON_ABIS="3.*"

PYTHON_MODNAME="logilab"
# Extra documentation (html/pdf) needs some love

src_prepare() {
	distutils_src_prepare

	# Disable broken test.
	sed -e "s/test_knownValues_is_standard_module_4/_&/" -i test/unittest_modutils.py

	# Disable tests failing when stdout is not a tty.
	sed \
		-e "s/test_both_capture/_&/" \
		-e "s/test_capture_core/_&/" \
		-i test/unittest_testlib.py

	if [[ "${EUID}" -eq 0 ]]; then
		# Disable tests failing with root permissions.
		sed \
			-e "s/test_mode_change/_&/" \
			-e "s/test_mode_change_on_append/_&/" \
			-e "s/test_restore_on_close/_&/" \
			-i test/unittest_fileutils.py
	fi
}

src_test() {
	testing() {
		# Install temporarily.
		local tpath="${T}/test-${PYTHON_ABI}"
		local spath="${tpath}$(python_get_sitedir)"

		"$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${tpath}" || die "Installation for tests failed with Python ${PYTHON_ABI}"

		# Bug 223079.
		if [[ "${EUID}" -eq 0 ]]; then
			rm test/unittest_fileutils.py || die
		fi

		# pytest picks up the tests relative to the current directory, so cd in. Do
		# not cd in too far though (to logilab/common for example) or some
		# relative/absolute module location tests fail.
		pushd "${spath}" >/dev/null || die
		PYTHONPATH="${spath}" "$(PYTHON)" "${tpath}/usr/bin/pytest" -v || return 1
		popd >/dev/null || die
	}
	python_execute_function testing
}

src_install() {
	distutils_src_install

	python_generate_wrapper_scripts -E -f -q "${ED}usr/bin/pytest"

	doman doc/pytest.1 || die "doman failed"

	# Don't install tests.
	rm -fr "${ED}"usr/lib*/python*/site-packages/${PN/-//}/test || die "Deletion of tests failed"
}