mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140481: Improve error message when trying to iterate a Tk widget, image or font (GH-140501)
This commit is contained in:
parent
ad0a3f733b
commit
09b1f10ef7
6 changed files with 59 additions and 22 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import collections.abc
|
||||
import functools
|
||||
import unittest
|
||||
import tkinter
|
||||
|
|
@ -508,6 +509,17 @@ def test_embedded_null(self):
|
|||
widget.selection_range(0, 'end')
|
||||
self.assertEqual(widget.selection_get(), '\u20ac\0abc\x00def')
|
||||
|
||||
def test_iterable_protocol(self):
|
||||
widget = tkinter.Entry(self.root)
|
||||
self.assertNotIsSubclass(tkinter.Entry, collections.abc.Iterable)
|
||||
self.assertNotIsSubclass(tkinter.Entry, collections.abc.Container)
|
||||
self.assertNotIsInstance(widget, collections.abc.Iterable)
|
||||
self.assertNotIsInstance(widget, collections.abc.Container)
|
||||
with self.assertRaisesRegex(TypeError, 'is not iterable'):
|
||||
iter(widget)
|
||||
with self.assertRaisesRegex(TypeError, 'is not a container or iterable'):
|
||||
widget in widget
|
||||
|
||||
|
||||
class WmTest(AbstractTkTest, unittest.TestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue