Created
August 27, 2022 19:26
-
-
Save pvanheus/a41aee46901d22012dd655facec91e5c to your computer and use it in GitHub Desktop.
patch nose 1.3.7 to work with Python 3.10+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ur nose.old/case.py nose/case.py | |
--- nose.old/case.py 2022-08-27 19:21:19.686914283 +0000 | |
+++ nose/case.py 2022-08-27 19:22:16.688908658 +0000 | |
@@ -9,7 +9,7 @@ | |
from nose.config import Config | |
from nose.failure import Failure # for backwards compatibility | |
from nose.util import resolve_name, test_address, try_run | |
-import collections | |
+from collections.abc import Callable | |
log = logging.getLogger(__name__) | |
@@ -27,7 +27,7 @@ | |
__test__ = False # do not collect | |
def __init__(self, test, config=None, resultProxy=None): | |
# sanity check | |
- if not isinstance(test, collections.Callable): | |
+ if not isinstance(test, Callable): | |
raise TypeError("nose.case.Test called with argument %r that " | |
"is not callable. A callable is required." | |
% test) | |
diff -ur nose.old/inspector.py nose/inspector.py | |
--- nose.old/inspector.py 2022-08-27 19:21:19.690914423 +0000 | |
+++ nose/inspector.py 2022-08-27 19:22:16.684908518 +0000 | |
@@ -7,7 +7,7 @@ | |
import sys | |
import textwrap | |
import tokenize | |
-import collections | |
+from collections.abc import Callable | |
try: | |
from io import StringIO | |
@@ -182,14 +182,14 @@ | |
# Clean this junk up | |
try: | |
val = self.locals[tok] | |
- if isinstance(val, collections.Callable): | |
+ if isinstance(val, Callable): | |
val = tok | |
else: | |
val = repr(val) | |
except KeyError: | |
try: | |
val = self.globals[tok] | |
- if isinstance(val, collections.Callable): | |
+ if isinstance(val, Callable): | |
val = tok | |
else: | |
val = repr(val) | |
diff -ur nose.old/loader.py nose/loader.py | |
--- nose.old/loader.py 2022-08-27 19:21:19.690914423 +0000 | |
+++ nose/loader.py 2022-08-27 19:22:16.684908518 +0000 | |
@@ -25,7 +25,7 @@ | |
transplant_class, test_address | |
from nose.suite import ContextSuiteFactory, ContextList, LazySuite | |
from nose.pyversion import sort_list, cmp_to_key | |
-import collections | |
+from collections.abc import Callable | |
log = logging.getLogger(__name__) | |
@@ -251,7 +251,7 @@ | |
try: | |
for test in g(): | |
test_func, arg = self.parseGeneratedTest(test) | |
- if not isinstance(test_func, collections.Callable): | |
+ if not isinstance(test_func, Callable): | |
test_func = getattr(m, test_func) | |
yield FunctionTestCase(test_func, arg=arg, descriptor=g) | |
except KeyboardInterrupt: | |
@@ -284,11 +284,11 @@ | |
try: | |
for test in g(): | |
test_func, arg = self.parseGeneratedTest(test) | |
- if not isinstance(test_func, collections.Callable): | |
+ if not isinstance(test_func, Callable): | |
test_func = unbound_method(c, getattr(c, test_func)) | |
if ismethod(test_func): | |
yield MethodTestCase(test_func, arg=arg, descriptor=g) | |
- elif isinstance(test_func, collections.Callable): | |
+ elif isinstance(test_func, Callable): | |
# In this case we're forcing the 'MethodTestCase' | |
# to run the inline function as its test call, | |
# but using the generator method as the 'method of | |
diff -ur nose.old/plugins/attrib.py nose/plugins/attrib.py | |
--- nose.old/plugins/attrib.py 2022-08-27 19:21:19.690914423 +0000 | |
+++ nose/plugins/attrib.py 2022-08-27 19:22:16.684908518 +0000 | |
@@ -107,7 +107,7 @@ | |
from inspect import isfunction | |
from nose.plugins.base import Plugin | |
from nose.util import tolist | |
-import collections | |
+from collections.abc import Callable | |
log = logging.getLogger('nose.plugins.attrib') | |
compat_24 = sys.version_info >= (2, 4) | |
@@ -239,7 +239,7 @@ | |
match = True | |
for key, value in group: | |
attr = get_method_attr(method, cls, key) | |
- if isinstance(value, collections.Callable): | |
+ if isinstance(value, Callable): | |
if not value(key, method, cls): | |
match = False | |
break | |
diff -ur nose.old/plugins/collect.py nose/plugins/collect.py | |
--- nose.old/plugins/collect.py 2022-08-27 19:21:19.690914423 +0000 | |
+++ nose/plugins/collect.py 2022-08-27 19:22:16.684908518 +0000 | |
@@ -14,7 +14,7 @@ | |
from nose.case import Test | |
import logging | |
import unittest | |
-import collections | |
+from collections.abc import Callable | |
log = logging.getLogger(__name__) | |
@@ -81,7 +81,7 @@ | |
def __init__(self, tests=(), conf=None): | |
self.conf = conf | |
# Exec lazy suites: makes discovery depth-first | |
- if isinstance(tests, collections.Callable): | |
+ if isinstance(tests, Callable): | |
tests = tests() | |
log.debug("TestSuite(%r)", tests) | |
unittest.TestSuite.__init__(self, tests) | |
diff -ur nose.old/suite.py nose/suite.py | |
--- nose.old/suite.py 2022-08-27 19:21:19.690914423 +0000 | |
+++ nose/suite.py 2022-08-27 19:22:16.688908658 +0000 | |
@@ -16,7 +16,7 @@ | |
from nose.config import Config | |
from nose.proxy import ResultProxyFactory | |
from nose.util import isclass, resolve_name, try_run | |
-import collections | |
+from collections.abc import Callable | |
if sys.platform == 'cli': | |
if sys.version_info[:2] < (2, 6): | |
@@ -103,7 +103,7 @@ | |
def _set_tests(self, tests): | |
self._precache = [] | |
is_suite = isinstance(tests, unittest.TestSuite) | |
- if isinstance(tests, collections.Callable) and not is_suite: | |
+ if isinstance(tests, Callable) and not is_suite: | |
self.test_generator = tests() | |
elif is_suite: | |
# Suites need special treatment: they must be called like | |
@@ -455,7 +455,7 @@ | |
ancestors.pop() | |
def findContext(self, tests): | |
- if isinstance(tests, collections.Callable) or isinstance(tests, unittest.TestSuite): | |
+ if isinstance(tests, Callable) or isinstance(tests, unittest.TestSuite): | |
return None | |
context = None | |
for test in tests: | |
@@ -538,7 +538,7 @@ | |
def wrapTests(self, tests): | |
log.debug("wrap %s", tests) | |
- if isinstance(tests, collections.Callable) or isinstance(tests, unittest.TestSuite): | |
+ if isinstance(tests, Callable) or isinstance(tests, unittest.TestSuite): | |
log.debug("I won't wrap") | |
return tests | |
wrapped = [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment