]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove unused branches from mock module (#106617)
authorChris Withers <chris@withers.org>
Tue, 11 Jul 2023 08:52:12 +0000 (09:52 +0100)
committerGitHub <noreply@github.com>
Tue, 11 Jul 2023 08:52:12 +0000 (08:52 +0000)
* lambda has a name of __none__, but no async lambda so this branch is not needed

* _get_signature_object only returns None for bound builtins. There are no async builtins so this branch isn't needed

* Exclude  a couple of methods from coverage checking in the downstream rolling backport of mock

Lib/test/test_unittest/testmock/testthreadingmock.py
Lib/unittest/mock.py

index c6f179490d01f8c4493547ecbb5469d00c3ebc2d..b6e12bcb3cda9ca3be1ae931f84419c165716c98 100644 (file)
@@ -11,10 +11,10 @@ threading_helper.requires_working_threading(module=True)
 
 class Something:
     def method_1(self):
-        pass
+        pass  # pragma: no cover
 
     def method_2(self):
-        pass
+        pass  # pragma: no cover
 
 
 class TestThreadingMock(unittest.TestCase):
index 3ed54b3ba230ed4a2987b8ee424ccee12f8d7823..e8c8360e0ae13e503a4689921eca05ca242d826b 100644 (file)
@@ -212,17 +212,12 @@ def _set_async_signature(mock, original, instance=False, is_async_mock=False):
     # signature as the original.
 
     skipfirst = isinstance(original, type)
-    result = _get_signature_object(original, instance, skipfirst)
-    if result is None:
-        return mock
-    func, sig = result
+    func, sig = _get_signature_object(original, instance, skipfirst)
     def checksig(*args, **kwargs):
         sig.bind(*args, **kwargs)
     _copy_func_details(func, checksig)
 
     name = original.__name__
-    if not name.isidentifier():
-        name = 'funcopy'
     context = {'_checksig_': checksig, 'mock': mock}
     src = """async def %s(*args, **kwargs):
     _checksig_(*args, **kwargs)