MCPcopy Index your code
hub / github.com/python/cpython / Func

Class Func

Lib/idlelib/idle_test/mock_idle.py:8–37  ·  view source on GitHub ↗

Record call, capture args, return/raise result set by test. When mock function is called, set or use attributes: self.called - increment call number even if no args, kwds passed. self.args - capture positional arguments. self.kwds - capture keyword arguments. self.result - retur

Source from the content-addressed store, hash-verified

6from idlelib.idle_test.mock_tk import Text
7
8class Func:
9 '''Record call, capture args, return/raise result set by test.
10
11 When mock function is called, set or use attributes:
12 self.called - increment call number even if no args, kwds passed.
13 self.args - capture positional arguments.
14 self.kwds - capture keyword arguments.
15 self.result - return or raise value set in __init__.
16 self.return_self - return self instead, to mock query class return.
17
18 Most common use will probably be to mock instance methods.
19 Given class instance, can set and delete as instance attribute.
20 Mock_tk.Var and Mbox_func are special variants of this.
21 '''
22 def __init__(self, result=None, return_self=False):
23 self.called = 0
24 self.result = result
25 self.return_self = return_self
26 self.args = None
27 self.kwds = None
28 def __call__(self, *args, **kwds):
29 self.called += 1
30 self.args = args
31 self.kwds = kwds
32 if isinstance(self.result, BaseException):
33 raise self.result
34 elif self.return_self:
35 return self
36 else:
37 return self.result
38
39
40class Editor:

Callers 15

list_keys_finalClass · 0.90
ValidatorClass · 0.90
list_keys_finalClass · 0.90
test_click_cancelMethod · 0.90
setUpClassMethod · 0.90
test_set_samplesMethod · 0.90
setUpClassMethod · 0.90
test_theme_sourceMethod · 0.90
test_colorMethod · 0.90
test_set_theme_typeMethod · 0.90
test_get_colorMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_click_cancelMethod · 0.72
setUpClassMethod · 0.72
test_set_samplesMethod · 0.72
setUpClassMethod · 0.72
test_theme_sourceMethod · 0.72
test_colorMethod · 0.72
test_set_theme_typeMethod · 0.72
test_get_colorMethod · 0.72
test_set_color_sampleMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…