Skip to content

Commit e6379f7

Browse files
authored
Remove unused branches from mock module (#106617)
* 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
1 parent 4bd8320 commit e6379f7

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

Lib/test/test_unittest/testmock/testthreadingmock.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
class Something:
1313
def method_1(self):
14-
pass
14+
pass # pragma: no cover
1515

1616
def method_2(self):
17-
pass
17+
pass # pragma: no cover
1818

1919

2020
class TestThreadingMock(unittest.TestCase):

Lib/unittest/mock.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,12 @@ def _set_async_signature(mock, original, instance=False, is_async_mock=False):
212212
# signature as the original.
213213

214214
skipfirst = isinstance(original, type)
215-
result = _get_signature_object(original, instance, skipfirst)
216-
if result is None:
217-
return mock
218-
func, sig = result
215+
func, sig = _get_signature_object(original, instance, skipfirst)
219216
def checksig(*args, **kwargs):
220217
sig.bind(*args, **kwargs)
221218
_copy_func_details(func, checksig)
222219

223220
name = original.__name__
224-
if not name.isidentifier():
225-
name = 'funcopy'
226221
context = {'_checksig_': checksig, 'mock': mock}
227222
src = """async def %s(*args, **kwargs):
228223
_checksig_(*args, **kwargs)

0 commit comments

Comments
 (0)