]> granicus.if.org Git - python/commitdiff
Issue #22769: Fixed ttk.Treeview.tag_has() when called without arguments.
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 7 Nov 2014 10:02:31 +0000 (12:02 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 7 Nov 2014 10:02:31 +0000 (12:02 +0200)
Lib/tkinter/test/test_ttk/test_widgets.py
Lib/tkinter/ttk.py
Misc/NEWS

index f73ac79184edf7e3eabd0dc8ef2b2b487ecbbd5f..8a27324d523728cf02628446ac7886b278ea375a 100644 (file)
@@ -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 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
             '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):
index 29d225c2d97a8ba87f5a9e1d8e55681d3039fd4a..4327dbb05d745be4e5b5fe26a12960f7c187ab48 100644 (file)
@@ -1456,7 +1456,11 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
         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))
 
 
index d31dbe9a3836d6db079f7627b2a10076a9bf743a..c4efc7c8afd4bf7c2afd1f241697be7e0991c0e3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -36,6 +36,8 @@ Core and Builtins
 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