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

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


https://hg.python.org/cpython/rev/b3a5b53173c0
changeset:   93421:b3a5b53173c0
branch:      2.7
parent:      93418:14a69e40dbb0
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Fri Nov 07 12:02:11 2014 +0200
summary:
  Issue #22769: Fixed ttk.Treeview.tag_has() when called without arguments.

files:
  Lib/lib-tk/test/test_ttk/test_widgets.py |  16 ++++++++++++
  Lib/lib-tk/ttk.py                        |   6 +++-
  Misc/NEWS                                |   2 +
  3 files changed, 23 insertions(+), 1 deletions(-)


diff --git a/Lib/lib-tk/test/test_ttk/test_widgets.py b/Lib/lib-tk/test/test_ttk/test_widgets.py
--- a/Lib/lib-tk/test/test_ttk/test_widgets.py
+++ b/Lib/lib-tk/test/test_ttk/test_widgets.py
@@ -1,5 +1,6 @@
 import unittest
 import Tkinter as tkinter
+from Tkinter import TclError
 import ttk
 from test.test_support import requires, run_unittest
 import sys
@@ -1564,6 +1565,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/lib-tk/ttk.py b/Lib/lib-tk/ttk.py
--- a/Lib/lib-tk/ttk.py
+++ b/Lib/lib-tk/ttk.py
@@ -1458,7 +1458,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
@@ -37,6 +37,8 @@
 Library
 -------
 
+- Issue #22769: Fixed ttk.Treeview.tag_has() when called without arguments.
+
 - Issue #22787: Allow the keyfile argument of SSLContext.load_cert_chain to be
   None.
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list