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

Class Mbox

Lib/idlelib/idle_test/mock_tk.py:59–91  ·  view source on GitHub ↗

Mock for tkinter.messagebox with an Mbox_func for each function. Example usage in test_module.py for testing functions in module.py: --- from idlelib.idle_test.mock_tk import Mbox import module orig_mbox = module.messagebox showerror = Mbox.showerror # example, for attribute access in tes

Source from the content-addressed store, hash-verified

57
58
59class Mbox:
60 """Mock for tkinter.messagebox with an Mbox_func for each function.
61
62 Example usage in test_module.py for testing functions in module.py:
63 ---
64from idlelib.idle_test.mock_tk import Mbox
65import module
66
67orig_mbox = module.messagebox
68showerror = Mbox.showerror # example, for attribute access in test methods
69
70class Test(unittest.TestCase):
71
72 @classmethod
73 def setUpClass(cls):
74 module.messagebox = Mbox
75
76 @classmethod
77 def tearDownClass(cls):
78 module.messagebox = orig_mbox
79 ---
80 For 'ask' functions, set func.result return value before calling the method
81 that uses the message function. When messagebox functions are the
82 only GUI calls in a method, this replacement makes the method GUI-free,
83 """
84 askokcancel = Mbox_func() # True or False
85 askquestion = Mbox_func() # 'yes' or 'no'
86 askretrycancel = Mbox_func() # True or False
87 askyesno = Mbox_func() # True or False
88 askyesnocancel = Mbox_func() # True, False, or None
89 showerror = Mbox_func() # None
90 showinfo = Mbox_func() # None
91 showwarning = Mbox_func() # None
92
93
94class Text:

Callers

nothing calls this directly

Calls 1

Mbox_funcClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…