Commit 42a4366a authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #26177: Fixed the keys() method for Canvas and Scrollbar widgets.

Added few missed tests for configure options.
parent 0554d83f
......@@ -1337,8 +1337,9 @@ class Misc:
self.configure({key: value})
def keys(self):
"""Return a list of all resource names of this widget."""
return [x[0][1:] for x in
self.tk.splitlist(self.tk.call(self._w, 'configure'))]
splitlist = self.tk.splitlist
return [splitlist(x)[0][1:] for x in
splitlist(self.tk.call(self._w, 'configure'))]
def __str__(self):
"""Return the window path name of this widget."""
return self._w
......
......@@ -12,6 +12,8 @@ requires('gui')
class PackTest(AbstractWidgetTest, unittest.TestCase):
test_keys = None
def create2(self):
pack = tkinter.Toplevel(self.root, name='pack')
pack.wm_geometry('300x200+0+0')
......@@ -276,6 +278,8 @@ class PackTest(AbstractWidgetTest, unittest.TestCase):
class PlaceTest(AbstractWidgetTest, unittest.TestCase):
test_keys = None
def create2(self):
t = tkinter.Toplevel(self.root, width=300, height=200, bd=0)
t.wm_geometry('300x200+0+0')
......@@ -478,6 +482,8 @@ class PlaceTest(AbstractWidgetTest, unittest.TestCase):
class GridTest(AbstractWidgetTest, unittest.TestCase):
test_keys = None
def tearDown(self):
cols, rows = self.root.grid_size()
for i in range(cols + 1):
......
......@@ -102,7 +102,7 @@ class FrameTest(AbstractToplevelTest, unittest.TestCase):
'background', 'borderwidth',
'class', 'colormap', 'container', 'cursor', 'height',
'highlightbackground', 'highlightcolor', 'highlightthickness',
'relief', 'takefocus', 'visual', 'width',
'padx', 'pady', 'relief', 'takefocus', 'visual', 'width',
)
def create(self, **kwargs):
......@@ -636,7 +636,7 @@ class CanvasTest(AbstractWidgetTest, unittest.TestCase):
'highlightbackground', 'highlightcolor', 'highlightthickness',
'insertbackground', 'insertborderwidth',
'insertofftime', 'insertontime', 'insertwidth',
'relief', 'scrollregion',
'offset', 'relief', 'scrollregion',
'selectbackground', 'selectborderwidth', 'selectforeground',
'state', 'takefocus',
'xscrollcommand', 'xscrollincrement',
......@@ -658,6 +658,15 @@ class CanvasTest(AbstractWidgetTest, unittest.TestCase):
widget = self.create()
self.checkBooleanParam(widget, 'confine')
def test_offset(self):
widget = self.create()
self.assertEqual(widget['offset'], '0,0')
self.checkParams(widget, 'offset',
'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center')
self.checkParam(widget, 'offset', '10,20')
self.checkParam(widget, 'offset', '#5,6')
self.checkInvalidParam(widget, 'offset', 'spam')
def test_scrollregion(self):
widget = self.create()
self.checkParam(widget, 'scrollregion', '0 0 200 150')
......
This diff is collapsed.
......@@ -206,6 +206,33 @@ class AbstractWidgetTest(AbstractTkTest):
break
def test_keys(self):
widget = self.create()
keys = widget.keys()
# XXX
if not isinstance(widget, Scale):
self.assertEqual(sorted(keys), sorted(widget.configure()))
for k in keys:
widget[k]
# Test if OPTIONS contains all keys
if test.support.verbose:
aliases = {
'bd': 'borderwidth',
'bg': 'background',
'fg': 'foreground',
'invcmd': 'invalidcommand',
'vcmd': 'validatecommand',
}
keys = set(keys)
expected = set(self.OPTIONS)
for k in sorted(keys - expected):
if not (k in aliases and
aliases[k] in keys and
aliases[k] in expected):
print('%s.OPTIONS doesn\'t contain "%s"' %
(self.__class__.__name__, k))
class StandardOptionsTests:
STANDARD_OPTIONS = (
'activebackground', 'activeborderwidth', 'activeforeground', 'anchor',
......
......@@ -91,6 +91,8 @@ Core and Builtins
Library
-------
- Issue #26177: Fixed the keys() method for Canvas and Scrollbar widgets.
- Issue #15068: Got rid of excessive buffering in the fileinput module.
The bufsize parameter is no longer used.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment