1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-21 10:15:12 +03:00
aports/community/py3-nose/py311-compat.patch
2022-11-22 20:33:36 +01:00

113 lines
4.9 KiB
Diff

Patch-Source: https://github.com/nose-devs/nose/pull/1117
From 5221885fd4fea96edff3e7692cef4531e166e15c Mon Sep 17 00:00:00 2001
From: Thomas A Caswell <tcaswell@gmail.com>
Date: Sat, 26 Sep 2015 23:50:21 -0400
Subject: [PATCH 1/4] MNT: hide getargspec usage for 3.6 compatibility
---
.travis.yml | 2 +-
nose/plugins/manager.py | 16 ++++++++++++++--
nose/util.py | 29 ++++++++++++++++++++++++-----
3 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/nose/plugins/manager.py b/nose/plugins/manager.py
index 04593f56..c7d882c7 100644
--- a/nose/plugins/manager.py
+++ b/nose/plugins/manager.py
@@ -104,8 +104,19 @@ def addPlugin(self, plugin, call):
"""
meth = getattr(plugin, call, None)
if meth is not None:
- if call == 'loadTestsFromModule' and \
- len(inspect.getargspec(meth)[0]) == 2:
+ try:
+ sig = inspect.signature(meth)
+ bl = set([inspect.Parameter.VAR_KEYWORD,
+ inspect.Parameter.VAR_POSITIONAL,
+ inspect.Parameter.KEYWORD_ONLY])
+ args = [k for k, v in sig.parameters.items()
+ if v.kind not in bl]
+ arg_len = len(args)
+ if hasattr(meth, '__self__'):
+ arg_len += 1
+ except AttributeError:
+ arg_len = len(inspect.getargspec(meth)[0])
+ if call == 'loadTestsFromModule' and arg_len == 2:
orig_meth = meth
meth = lambda module, path, **kwargs: orig_meth(module)
self.plugins.append((plugin, meth))
@@ -153,6 +164,7 @@ def generate(self, *arg, **kw):
if result is not None:
for r in result:
yield r
+
except (KeyboardInterrupt, SystemExit):
raise
except:
diff --git a/nose/util.py b/nose/util.py
index bfe16589..9ec9c3ed 100644
--- a/nose/util.py
+++ b/nose/util.py
@@ -449,16 +449,35 @@ def try_run(obj, names):
if type(obj) == types.ModuleType:
# py.test compatibility
if isinstance(func, types.FunctionType):
- args, varargs, varkw, defaults = \
- inspect.getargspec(func)
+ try:
+ sig = inspect.signature(func)
+ bl = set([inspect.Parameter.VAR_KEYWORD,
+ inspect.Parameter.VAR_POSITIONAL,
+ inspect.Parameter.KEYWORD_ONLY])
+ args = [k for k, v in sig.parameters.items()
+ if v.kind not in bl]
+ except AttributeError:
+ args, varargs, varkw, defaults = \
+ inspect.getargspec(func)
+
else:
# Not a function. If it's callable, call it anyway
if hasattr(func, '__call__') and not inspect.ismethod(func):
func = func.__call__
try:
- args, varargs, varkw, defaults = \
- inspect.getargspec(func)
- args.pop(0) # pop the self off
+ try:
+ sig = inspect.signature(func)
+ bl = set([inspect.Parameter.VAR_KEYWORD,
+ inspect.Parameter.VAR_POSITIONAL,
+ inspect.Parameter.KEYWORD_ONLY])
+ args = [k for k, v in sig.parameters.items()
+ if v.kind not in bl]
+
+ except AttributeError:
+ args, varargs, varkw, defaults = \
+ inspect.getargspec(func)
+ # signature never returns it
+ args.pop(0) # pop the self off
except TypeError:
raise TypeError("Attribute %s of %r is not a python "
"function. Only functions or callables"
From 8debb4e21b542e92f19502550d65a81f9ed2a2ed Mon Sep 17 00:00:00 2001
From: Tim Gates <tim.gates@iress.com>
Date: Mon, 4 Jul 2022 07:17:23 +1000
Subject: [PATCH 4/4] Update util.py
---
nose/util.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/nose/util.py b/nose/util.py
index a05d763f..6a436fc2 100644
--- a/nose/util.py
+++ b/nose/util.py
@@ -476,7 +476,6 @@ def try_run(obj, names):
except AttributeError:
args, varargs, varkw, defaults = \
inspect.getargspec(func)
- # signature never returns it
args.pop(0) # pop the self off
except TypeError:
raise TypeError("Attribute %s of %r is not a python "