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
This commit is contained in:
Chris Withers 2023-07-11 09:52:12 +01:00 committed by GitHub
parent 4bd8320dd7
commit e6379f72cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 8 deletions

View 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):

View 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)