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

Method test_invoke

Lib/test/test_ttk/test_widgets.py:271–298  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

269 self.checkParams(widget, 'onvalue', 1, 2.3, '', 'any string')
270
271 def test_invoke(self):
272 success = []
273 def cb_test():
274 success.append(1)
275 return "cb test called"
276
277 cbtn = ttk.Checkbutton(self.root, command=cb_test)
278 # the variable automatically created by ttk.Checkbutton is actually
279 # undefined till we invoke the Checkbutton
280 self.assertEqual(cbtn.state(), ('alternate', ))
281 self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar,
282 cbtn['variable'])
283
284 res = cbtn.invoke()
285 self.assertEqual(res, "cb test called")
286 self.assertEqual(cbtn['onvalue'],
287 cbtn.tk.globalgetvar(cbtn['variable']))
288 self.assertTrue(success)
289
290 cbtn['command'] = ''
291 res = cbtn.invoke()
292 if tk_version >= (8, 7) and self.wantobjects:
293 self.assertEqual(res, ())
294 else:
295 self.assertEqual(str(res), '')
296 self.assertLessEqual(len(success), 1)
297 self.assertEqual(cbtn['offvalue'],
298 cbtn.tk.globalgetvar(cbtn['variable']))
299
300 def test_unique_variables(self):
301 frames = []

Callers

nothing calls this directly

Calls 7

invokeMethod · 0.95
strFunction · 0.85
assertTrueMethod · 0.80
assertLessEqualMethod · 0.80
assertEqualMethod · 0.45
stateMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected