@@ -256,6 +256,7 @@ def reset_mock():
256256 ret .reset_mock ()
257257
258258 funcopy .called = False
259+ funcopy .call_count = 0
259260 funcopy .call_args = None
260261 funcopy .call_args_list = _CallList ()
261262 funcopy .method_calls = _CallList ()
@@ -489,6 +490,7 @@ def __init__(
489490
490491 __dict__ ['_mock_called' ] = False
491492 __dict__ ['_mock_call_args' ] = None
493+ __dict__ ['_mock_call_count' ] = 0
492494 __dict__ ['_mock_call_args_list' ] = _CallList ()
493495 __dict__ ['_mock_mock_calls' ] = _CallList ()
494496
@@ -605,17 +607,10 @@ def __class__(self):
605607
606608 called = _delegating_property ('called' )
607609 call_args = _delegating_property ('call_args' )
610+ call_count = _delegating_property ('call_count' )
608611 call_args_list = _delegating_property ('call_args_list' )
609612 mock_calls = _delegating_property ('mock_calls' )
610613
611- @property
612- def call_count (self ):
613- sig = self ._mock_delegate
614- if sig is None :
615- return len (self ._mock_call_args_list )
616- return len (sig .call_args_list )
617-
618-
619614 def __get_side_effect (self ):
620615 delegated = self ._mock_delegate
621616 if delegated is None :
@@ -650,6 +645,7 @@ def reset_mock(self, visited=None, *,
650645
651646 self .called = False
652647 self .call_args = None
648+ self .call_count = 0
653649 self .mock_calls = _CallList ()
654650 self .call_args_list = _CallList ()
655651 self .method_calls = _CallList ()
@@ -1190,6 +1186,7 @@ def _increment_mock_call(self, /, *args, **kwargs):
11901186 _call = _Call ((args , kwargs ), two = True )
11911187 self .call_args = _call
11921188 self .call_args_list .append (_call )
1189+ self .call_count = len (self .call_args_list )
11931190
11941191 # initial stuff for method_calls:
11951192 do_method_calls = self ._mock_parent is not None
0 commit comments