summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-05-05 16:21:51 +0200
committerMichał Górny <mgorny@gentoo.org>2021-05-05 19:05:40 +0200
commit0204f5b41216a0403e1b7d75704f8a3d49cb6d9f (patch)
tree88c5d7de1258ad0602396e2bceb32897fbaa9cc8 /dev-python/mock
parentdev-python/pretend: Enable python3.10 (diff)
downloadgentoo-0204f5b41216a0403e1b7d75704f8a3d49cb6d9f.tar.gz
gentoo-0204f5b41216a0403e1b7d75704f8a3d49cb6d9f.tar.bz2
gentoo-0204f5b41216a0403e1b7d75704f8a3d49cb6d9f.zip
dev-python/mock: Enable python3.10
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/mock')
-rw-r--r--dev-python/mock/files/mock-4.0.3-py310.patch76
-rw-r--r--dev-python/mock/mock-4.0.3.ebuild15
2 files changed, 82 insertions, 9 deletions
diff --git a/dev-python/mock/files/mock-4.0.3-py310.patch b/dev-python/mock/files/mock-4.0.3-py310.patch
new file mode 100644
index 000000000000..4a096f35126c
--- /dev/null
+++ b/dev-python/mock/files/mock-4.0.3-py310.patch
@@ -0,0 +1,76 @@
+From f3e3d82aab0ede7e25273806dc0505574d85eae2 Mon Sep 17 00:00:00 2001
+From: Chris Withers <chris@simplistix.co.uk>
+Date: Thu, 15 Apr 2021 08:27:25 +0100
+Subject: [PATCH] fix tests that should test mock but were testing
+ unittest.mock
+
+---
+ mock/tests/testmock.py | 15 ++++++++-------
+ 1 file changed, 8 insertions(+), 7 deletions(-)
+
+diff --git a/mock/tests/testmock.py b/mock/tests/testmock.py
+index 5702b6d..1a70909 100644
+--- a/mock/tests/testmock.py
++++ b/mock/tests/testmock.py
+@@ -13,6 +13,7 @@ from mock import (
+ create_autospec, mock
+ )
+ from mock.mock import _Call, _CallList
++import mock.mock as mock_module
+
+
+ class Iter(object):
+@@ -47,7 +48,7 @@ class MockTest(unittest.TestCase):
+ # if __all__ is badly defined then import * will raise an error
+ # We have to exec it because you can't import * inside a method
+ # in Python 3
+- exec("from unittest.mock import *")
++ exec("from mock.mock import *")
+
+
+ def test_constructor(self):
+@@ -2137,16 +2138,16 @@ class MockTest(unittest.TestCase):
+ # test_patch_dict_test_prefix and test_patch_test_prefix not restoring
+ # causes the objects patched to go out of sync
+
+- old_patch = unittest.mock.patch
++ old_patch = mock_module.patch
+
+ # Directly using __setattr__ on unittest.mock causes current imported
+ # reference to be updated. Use a lambda so that during cleanup the
+ # re-imported new reference is updated.
+- self.addCleanup(lambda patch: setattr(unittest.mock, 'patch', patch),
++ self.addCleanup(lambda patch: setattr(mock_module, 'patch', patch),
+ old_patch)
+
+ with patch.dict('sys.modules'):
+- del sys.modules['unittest.mock']
++ del sys.modules['mock']
+
+ # This trace will stop coverage being measured ;-)
+ def trace(frame, event, arg): # pragma: no cover
+@@ -2155,7 +2156,7 @@ class MockTest(unittest.TestCase):
+ self.addCleanup(sys.settrace, sys.gettrace())
+ sys.settrace(trace)
+
+- from unittest.mock import (
++ from mock.mock import (
+ Mock, MagicMock, NonCallableMock, NonCallableMagicMock
+ )
+
+@@ -2170,10 +2171,10 @@ class MockTest(unittest.TestCase):
+ def test_bool_not_called_when_passing_spec_arg(self):
+ class Something:
+ def __init__(self):
+- self.obj_with_bool_func = unittest.mock.MagicMock()
++ self.obj_with_bool_func = mock_module.MagicMock()
+
+ obj = Something()
+- with unittest.mock.patch.object(obj, 'obj_with_bool_func', autospec=True): pass
++ with mock_module.patch.object(obj, 'obj_with_bool_func', autospec=True): pass
+
+ self.assertEqual(obj.obj_with_bool_func.__bool__.call_count, 0)
+
+--
+2.31.1
+
diff --git a/dev-python/mock/mock-4.0.3.ebuild b/dev-python/mock/mock-4.0.3.ebuild
index d8149f697701..be913d227c1f 100644
--- a/dev-python/mock/mock-4.0.3.ebuild
+++ b/dev-python/mock/mock-4.0.3.ebuild
@@ -3,7 +3,7 @@
EAPI=7
-PYTHON_COMPAT=( python3_{7,8,9} pypy3 )
+PYTHON_COMPAT=( python3_{7..10} pypy3 )
inherit distutils-r1
@@ -16,12 +16,12 @@ SLOT="0"
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
RDEPEND="
- $(python_gen_cond_dep '
- dev-python/funcsigs[${PYTHON_USEDEP}]
- ' -2)
>=dev-python/six-1.9[${PYTHON_USEDEP}]"
-DEPEND="${RDEPEND}
- >=dev-python/setuptools-17.1[${PYTHON_USEDEP}]"
+BDEPEND=${RDEPEND}
+
+PATCHES=(
+ "${FILESDIR}"/${P}-py310.patch
+)
src_prepare() {
sed -i -e '/ pytest.*/d' setup.cfg || die
@@ -35,9 +35,6 @@ python_test() {
# test filtering.
cp -r mock/tests "${BUILD_DIR}"/lib/mock/ || die
cd "${BUILD_DIR}"/lib || die
- if ! python_is_python3; then
- rm mock/tests/*py3* || die
- fi
# https://github.com/testing-cabal/mock/commit/d6b42149bb87cf38729eef8a100c473f602ef7fa
if [[ ${EPYTHON} == pypy* ]]; then