40faa14a526299688d5b93d4381eb8f56cf38d94
[gentoo.git] / dev-python / mock / mock-3.0.5-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_{6,7,8} pypy3 )
7
8 inherit distutils-r1
9
10 DESCRIPTION="Rolling backport of unittest.mock for all Pythons"
11 HOMEPAGE="https://github.com/testing-cabal/mock"
12 SRC_URI="https://github.com/testing-cabal/mock/archive/${PV}.tar.gz -> ${P}.gh.tar.gz"
13
14 LICENSE="BSD"
15 SLOT="0"
16 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos"
17
18 RDEPEND="
19         >=virtual/python-funcsigs-1[${PYTHON_USEDEP}]
20         >=dev-python/six-1.9[${PYTHON_USEDEP}]"
21 DEPEND="${RDEPEND}
22         >=dev-python/setuptools-17.1[${PYTHON_USEDEP}]"
23
24 python_test() {
25         # Upstream supports running tests only in their dream pristine
26         # environment.  pytest doesn't work at all if mock is already
27         # installed.  We can use plain unittest but we have to reinvent
28         # test filtering.
29         cp -r mock/tests "${BUILD_DIR}"/lib/mock/ || die
30         cd "${BUILD_DIR}"/lib || die
31         if ! python_is_python3; then
32                 rm mock/tests/*py3* || die
33         fi
34
35         # https://github.com/testing-cabal/mock/commit/d6b42149bb87cf38729eef8a100c473f602ef7fa
36         if [[ ${EPYTHON} == pypy* ]]; then
37                 sed -i -e 's:def test_copy:def _test_copy:' \
38                         mock/tests/testmock.py || die
39         fi
40
41         "${EPYTHON}" -m unittest discover -v || die "Tests failed with ${EPYTHON}"
42 }
43
44 python_install_all() {
45         local DOCS=( CHANGELOG.rst README.rst )
46
47         distutils-r1_python_install_all
48 }