[Python-checkins] cpython (3.4): Issue #22769: Fixed ttk.Treeview.tag_has() when called without arguments.

serhiy.storchaka python-checkins at python.org
Fri Nov 7 11:12:38 CET 2014


https://hg.python.org/cpython/rev/cd17aa63492e
changeset: 93422:cd17aa63492e
branch: 3.4
parent: 93419:540b022ae7a9
user: Serhiy Storchaka <storchaka at gmail.com>
date: Fri Nov 07 12:02:31 2014 +0200
summary:
 Issue #22769: Fixed ttk.Treeview.tag_has() when called without arguments.
files:
 Lib/tkinter/test/test_ttk/test_widgets.py | 17 ++++++++++-
 Lib/tkinter/ttk.py | 6 +++-
 Misc/NEWS | 2 +
 3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py
--- a/Lib/tkinter/test/test_ttk/test_widgets.py
+++ b/Lib/tkinter/test/test_ttk/test_widgets.py
@@ -1,6 +1,6 @@
 import unittest
 import tkinter
-from tkinter import ttk
+from tkinter import ttk, TclError
 from test.support import requires
 import sys
 
@@ -1563,6 +1563,21 @@
 'blue')
 self.assertIsInstance(self.tv.tag_configure('test'), dict)
 
+ def test_tag_has(self):
+ item1 = self.tv.insert('', 'end', text='Item 1', tags=['tag1'])
+ item2 = self.tv.insert('', 'end', text='Item 2', tags=['tag2'])
+ self.assertRaises(TypeError, self.tv.tag_has)
+ self.assertRaises(TclError, self.tv.tag_has, 'tag1', 'non-existing')
+ self.assertTrue(self.tv.tag_has('tag1', item1))
+ self.assertFalse(self.tv.tag_has('tag1', item2))
+ self.assertFalse(self.tv.tag_has('tag2', item1))
+ self.assertTrue(self.tv.tag_has('tag2', item2))
+ self.assertFalse(self.tv.tag_has('tag3', item1))
+ self.assertFalse(self.tv.tag_has('tag3', item2))
+ self.assertEqual(self.tv.tag_has('tag1'), (item1,))
+ self.assertEqual(self.tv.tag_has('tag2'), (item2,))
+ self.assertEqual(self.tv.tag_has('tag3'), ())
+
 
 @add_standard_options(StandardTtkOptionsTests)
 class SeparatorTest(AbstractWidgetTest, unittest.TestCase):
diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py
--- a/Lib/tkinter/ttk.py
+++ b/Lib/tkinter/ttk.py
@@ -1456,7 +1456,11 @@
 all items which have the specified tag.
 
 * Availability: Tk 8.6"""
- return self.tk.getboolean(
+ if item is None:
+ return self.tk.splitlist(
+ self.tk.call(self._w, "tag", "has", tagname))
+ else:
+ return self.tk.getboolean(
 self.tk.call(self._w, "tag", "has", tagname, item))
 
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -36,6 +36,8 @@
 Library
 -------
 
+- Issue #22769: Fixed ttk.Treeview.tag_has() when called without arguments.
+
 - Issue #22417: Verify certificates by default in httplib (PEP 476).
 
 - Issue #22775: Fixed unpickling of http.cookies.SimpleCookie with protocol 2
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /