Call functools.update_wrapper on Mock(wraps=func)

Dec. 30, 2022
2:10 p.m.
For code that uses annotations / signature, wrapping a callable in a Mock object does not work correctly:
It's relatively simple to call update_wrapper on your own, but it seems like it would be better if the mock "just worked" for code that tries to use signature and annotations at runtime. I think all that's required would be adding `if wraps is not None: functools.update_wrapper(self, wraps)` after the line here: https://github.com/python/cpython/blob/f4fcfdf8c593611f98b9358cc0c5604c15306... Does anyone see any problems with implementing this? Thanks & best wishes, Lucas Wiman
787
Age (days ago)
787
Last active (days ago)
0 comments
1 participants
participants (1)
-
Lucas Wiman