diff options
Diffstat (limited to 'dev-python/flexmock')
-rw-r--r-- | dev-python/flexmock/Manifest | 3 | ||||
-rw-r--r-- | dev-python/flexmock/files/flexmock-0.10.6-fix-with_args-sys.stdout.write.patch | 60 | ||||
-rw-r--r-- | dev-python/flexmock/flexmock-0.10.6.ebuild | 27 |
3 files changed, 90 insertions, 0 deletions
diff --git a/dev-python/flexmock/Manifest b/dev-python/flexmock/Manifest index 963c3b6e6507..fab531117341 100644 --- a/dev-python/flexmock/Manifest +++ b/dev-python/flexmock/Manifest @@ -1,3 +1,6 @@ +AUX flexmock-0.10.6-fix-with_args-sys.stdout.write.patch 2707 BLAKE2B 9848593b70aca7e118c4a787c2e153e15982eb5f403b1883d484bdd2d22efd8b6d9ff2d9e1bb3e4699215e9c15cb0d5cff8ac2b571e6d87aa0186fa416981cd9 SHA512 3ba7f4ae532670e9576e9e060e0e4a1d0530ae7ab4f0e40e6e20e103e64030d2e5a0900e412d3006e7864e6d67976ee22f2067af7611f21f9400dd7c421b0ebb DIST flexmock-0.10.4.tar.gz 45362 BLAKE2B 4ff79cff3b0d8fb0c97bd60b0d5aa5555a7b939d3d6275a17c9bd1002b1d7acb53d4f63f5f834faf0d349d8b8d429eb063f121c4d7b6d12aa1bb3e7bdbadb861 SHA512 d190fcb66f0c2c4e3be2384d68b95a22c695ffa0fe8f8a218f2baa68c91683641396197cac69ddab21e4b0990b9930f56423bb7cd85770ceade9c22ece72cedc +DIST flexmock-0.10.6.tar.gz 46740 BLAKE2B b5c8083694e8787e85ff0f41265ad9f716a4c82d274ca5c793b6d93bf8bf28f3e57afd33f7ba59149e75f7bffbebd3843901dfa75caaefc6f76f3eef0c603314 SHA512 2ebaed78926f01bd4d886a509d978d0de04629f7d96c48f846b8ccf7906bb2303e7cbeab8226c6eb98d058f940434144cc2d6300d6aa2533f1f217788211490e EBUILD flexmock-0.10.4.ebuild 489 BLAKE2B f22dc9131f02343a598a8b61546184bee128d54de48acd2de913f6ef48121438323a0c7c169ad9c8761628f44923147403761e46c59bc5f302c48ec32ddb1be9 SHA512 e389dd36a35931b8d2a7354b32ab3155e3475f92332aee2040576ade042cf9b30310292e0d0925e61cc647993ab857d3e4ad7ccc12198c080f95e11cf2f1a217 +EBUILD flexmock-0.10.6.ebuild 560 BLAKE2B 40aa46b1ae2147d22b801a2723d66258bf64838aa50d1e3462d8dd1a1b1f2a6fc8906e76be2e13230a33dfcb173d8f2de0e63802c83023f3a456165a25787f45 SHA512 76bafaa5b4a816f9eb79b52548a79ddb3abbff67b2b3a1e97e250fcd7d10d4f047258a691b582789faf16aa60756bef424dac298508b0b71ce3d7d2ee3f01294 MISC metadata.xml 657 BLAKE2B 065a19cc94f756b0702f9b52010d5ac63af8d3b8f67ea307a073f0ff6046143e2d2e4f4266df5324192e42c4ce823fff646188654207cd87277d854c986d2667 SHA512 c2cfa313f94d79e0cce3213f53449582e18edfdbdb244d9771aed0f4e610e2a7ab225b0d7d51483be9c1ac9763c376f051b45fffc1f83ca44bd06017c0b29a06 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 +} |