summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2021-08-19 20:43:52 +0300
committerArthur Zamarin <arthurzam@gentoo.org>2021-08-19 20:45:19 +0300
commitb62ed597a209744882d3e4a9e777bad39351cbd9 (patch)
tree28a46619e74ebf6997385d9ae4d043e98af45bd5 /dev-python/flexmock
parentmedia-video/mjpegtools: Remove old. (diff)
downloadgentoo-b62ed597a209744882d3e4a9e777bad39351cbd9.tar.gz
gentoo-b62ed597a209744882d3e4a9e777bad39351cbd9.tar.bz2
gentoo-b62ed597a209744882d3e4a9e777bad39351cbd9.zip
dev-python/flexmock: add 0.10.6, fix for borgmatic
Closes: https://bugs.gentoo.org/740128 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'dev-python/flexmock')
-rw-r--r--dev-python/flexmock/Manifest1
-rw-r--r--dev-python/flexmock/files/flexmock-0.10.6-fix-with_args-sys.stdout.write.patch60
-rw-r--r--dev-python/flexmock/flexmock-0.10.6.ebuild27
3 files changed, 88 insertions, 0 deletions
diff --git a/dev-python/flexmock/Manifest b/dev-python/flexmock/Manifest
index d324f235d092..187d09bbe454 100644
--- a/dev-python/flexmock/Manifest
+++ b/dev-python/flexmock/Manifest
@@ -1 +1,2 @@
DIST flexmock-0.10.4.tar.gz 45362 BLAKE2B 4ff79cff3b0d8fb0c97bd60b0d5aa5555a7b939d3d6275a17c9bd1002b1d7acb53d4f63f5f834faf0d349d8b8d429eb063f121c4d7b6d12aa1bb3e7bdbadb861 SHA512 d190fcb66f0c2c4e3be2384d68b95a22c695ffa0fe8f8a218f2baa68c91683641396197cac69ddab21e4b0990b9930f56423bb7cd85770ceade9c22ece72cedc
+DIST flexmock-0.10.6.tar.gz 46740 BLAKE2B b5c8083694e8787e85ff0f41265ad9f716a4c82d274ca5c793b6d93bf8bf28f3e57afd33f7ba59149e75f7bffbebd3843901dfa75caaefc6f76f3eef0c603314 SHA512 2ebaed78926f01bd4d886a509d978d0de04629f7d96c48f846b8ccf7906bb2303e7cbeab8226c6eb98d058f940434144cc2d6300d6aa2533f1f217788211490e
diff --git a/dev-python/flexmock/files/flexmock-0.10.6-fix-with_args-sys.stdout.write.patch b/dev-python/flexmock/files/flexmock-0.10.6-fix-with_args-sys.stdout.write.patch
new file mode 100644
index 000000000000..0c3988e41788
--- /dev/null
+++ b/dev-python/flexmock/files/flexmock-0.10.6-fix-with_args-sys.stdout.write.patch
@@ -0,0 +1,60 @@
+From 020ebef66523e9496f8042beb9384f3f770a6412 Mon Sep 17 00:00:00 2001
+From: Arthur Zamarin <arthurzam@gentoo.org>
+Date: Thu, 19 Aug 2021 20:39:04 +0300
+Subject: [PATCH] Fix with_args not working with sys.stdout.write
+
+https://github.com/flexmock/flexmock/commit/513265e731fc4daceeb19123a4e71d652b990a1a
+
+Backported to 0.10.6 by Arthur Zamarin <arthurzam@gentoo.org>
+
+--- a/flexmock.py
++++ b/flexmock.py
+@@ -254,13 +254,13 @@ class Expectation(object):
+ # - it's not a static method
+ # - the mocked object is a module - module "methods" are in fact plain functions;
+ # unless they're classes, which means they still have __init__
+- is_method = ((inspect.ismethod(self.original) or inspect.isfunction(self.original)
+- or _isclass(self.original)) and
+- self.method_type is not staticmethod and
+- (not isinstance(self._mock, types.ModuleType) or
+- _isclass(self.original)))
++ is_builtin_method = isinstance(self.original, types.BuiltinMethodType)
++ is_method = inspect.ismethod(self.original) and self.method_type is not staticmethod
++ is_class = inspect.isclass(self.original)
++ is_class_method = (inspect.isfunction(self.original) and inspect.isclass(self.mock)
++ and self.method_type is not staticmethod)
+ args_len = len(allowed.args)
+- if is_method:
++ if is_builtin_method or is_method or is_class or is_class_method:
+ args_len -= 1
+ minimum = args_len - (allowed.defaults and len(allowed.defaults) or 0)
+ maximum = None
+--- a/tests/flexmock_test.py
++++ b/tests/flexmock_test.py
+@@ -17,6 +17,7 @@ from flexmock import ReturnValue
+ from flexmock import flexmock_teardown
+ from flexmock import _format_args
+ from flexmock import _isproperty
++import random
+ import flexmock
+ import re
+ import sys
+@@ -308,6 +309,15 @@ class RegularClass(object):
+ assertEqual('got an int', mock.method_foo(23))
+ assertRaises(MethodSignatureError, mock.method_foo, 2.0)
+
++ def test_with_args_should_work_with_builtin_c_functions_and_methods(self):
++ flexmock(sys.stdout).should_call("write") # set fall-through
++ flexmock(sys.stdout).should_receive("write").with_args("flexmock_builtin_test").once()
++ sys.stdout.write("flexmock_builtin_test")
++
++ def test_with_args_should_work_with_builtin_python_methods(self):
++ flexmock(random).should_receive("randint").with_args(1, 10).once()
++ random.randint(1, 10)
++
+ def test_flexmock_should_match_expectations_against_user_defined_classes(self):
+ mock = flexmock(name='temp')
+
+--
+2.33.0
+
diff --git a/dev-python/flexmock/flexmock-0.10.6.ebuild b/dev-python/flexmock/flexmock-0.10.6.ebuild
new file mode 100644
index 000000000000..7280fd3db06f
--- /dev/null
+++ b/dev-python/flexmock/flexmock-0.10.6.ebuild
@@ -0,0 +1,27 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{8..10} pypy3 )
+
+inherit distutils-r1
+
+DESCRIPTION="Testing library to create mocks, stubs and fakes"
+HOMEPAGE="https://flexmock.readthedocs.org/"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~riscv"
+
+distutils_enable_tests pytest
+
+PATCHES=(
+ "${FILESDIR}/${P}-fix-with_args-sys.stdout.write.patch"
+)
+
+python_install_all() {
+ distutils-r1_python_install_all
+ dodoc -r docs
+}