summaryrefslogtreecommitdiffstats
path: root/Lib/lib-tk
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-11-03 12:28:29 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-11-03 12:28:29 (GMT)
commit31b9c845d315d107c18384a17991010ca54b36f7 (patch)
tree46c20e756ff2dd2ba6f8dec180953816809964ee /Lib/lib-tk
parent8630f16eb7393649d501dd3f6982d15c799e24ee (diff)
downloadcpython-31b9c845d315d107c18384a17991010ca54b36f7.zip
cpython-31b9c845d315d107c18384a17991010ca54b36f7.tar.gz
cpython-31b9c845d315d107c18384a17991010ca54b36f7.tar.bz2
Issue #6157: Fixed Tkinter.Text.debug(). Original patch by Guilherme Polo.
Diffstat (limited to 'Lib/lib-tk')
-rw-r--r--Lib/lib-tk/Tkinter.py5
-rw-r--r--Lib/lib-tk/test/test_tkinter/test_text.py11
-rw-r--r--Lib/lib-tk/test/test_tkinter/test_widgets.py13
3 files changed, 27 insertions, 2 deletions
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 6ad0cf1..718be6e 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -2908,8 +2908,9 @@ class Text(Widget, XView, YView):
def debug(self, boolean=None):
"""Turn on the internal consistency checks of the B-Tree inside the text
widget according to BOOLEAN."""
- return self.tk.getboolean(self.tk.call(
- self._w, 'debug', boolean))
+ if boolean is None:
+ return self.tk.call(self._w, 'debug')
+ self.tk.call(self._w, 'debug', boolean)
def delete(self, index1, index2=None):
"""Delete the characters between INDEX1 and INDEX2 (not included)."""
self.tk.call(self._w, 'delete', index1, index2)
diff --git a/Lib/lib-tk/test/test_tkinter/test_text.py b/Lib/lib-tk/test/test_tkinter/test_text.py
index e6c08be..ca21b60 100644
--- a/Lib/lib-tk/test/test_tkinter/test_text.py
+++ b/Lib/lib-tk/test/test_tkinter/test_text.py
@@ -14,6 +14,17 @@ class TextTest(unittest.TestCase):
def tearDown(self):
self.text.destroy()
+ def test_debug(self):
+ text = self.text
+ olddebug = text.debug()
+ try:
+ text.debug(0)
+ self.assertEqual(text.debug(), 0)
+ text.debug(1)
+ self.assertEqual(text.debug(), 1)
+ finally:
+ text.debug(olddebug)
+ self.assertEqual(text.debug(), olddebug)
def test_search(self):
text = self.text
diff --git a/Lib/lib-tk/test/test_tkinter/test_widgets.py b/Lib/lib-tk/test/test_tkinter/test_widgets.py
index cfbc0b3..3042599 100644
--- a/Lib/lib-tk/test/test_tkinter/test_widgets.py
+++ b/Lib/lib-tk/test/test_tkinter/test_widgets.py
@@ -607,6 +607,19 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
else:
self.checkEnumParam(widget, 'wrap', 'char', 'none', 'word')
+ def test_bbox(self):
+ widget = self.create()
+ bbox = widget.bbox('1.1')
+ self.assertEqual(len(bbox), 4)
+ for item in bbox:
+ self.assertIsInstance(item, int)
+
+ self.assertIsNone(widget.bbox('end'))
+ self.assertRaises(Tkinter.TclError, widget.bbox, 'noindex')
+ self.assertRaises(Tkinter.TclError, widget.bbox, None)
+ self.assertRaises(Tkinter.TclError, widget.bbox)
+ self.assertRaises(Tkinter.TclError, widget.bbox, '1.1', 'end')
+
@add_standard_options(PixelSizeTests, StandardOptionsTests)
class CanvasTest(AbstractWidgetTest, unittest.TestCase):