Skip to content

Commit

Permalink
Remove unused branches from mock module (#106617)
Browse files Browse the repository at this point in the history
* 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

Backports: e6379f72cbc60f6b3c5676f9e225d4f145d5693f
Signed-off-by: Chris Withers <[email protected]>
  • Loading branch information
cjw296 committed Jul 11, 2023
1 parent f0cc385 commit 7334319
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions mock/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,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)
Expand Down
4 changes: 2 additions & 2 deletions mock/tests/testthreadingmock.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

class Something:
def method_1(self):
pass
pass # pragma: no cover

def method_2(self):
pass
pass # pragma: no cover


class TestThreadingMock(unittest.TestCase):
Expand Down

0 comments on commit 7334319

Please sign in to comment.