summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/test/test_tkinter/test_widgets.py
diff options
context:
space:
mode:
authorJuliette Monsel <j4321@users.noreply.github.com>2018-10-08 16:29:24 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-10-08 16:29:24 (GMT)
commitaf5658ae93b0a87ab4420a7dc30a07fa5a83e252 (patch)
tree88fc472ba5b1de85818b1603c7b69ba19addc3d4 /Lib/tkinter/test/test_tkinter/test_widgets.py
parenta8d5e2f255f1a20fc8af7dc16a7cb708e014952a (diff)
downloadcpython-af5658ae93b0a87ab4420a7dc30a07fa5a83e252.zip
cpython-af5658ae93b0a87ab4420a7dc30a07fa5a83e252.tar.gz
cpython-af5658ae93b0a87ab4420a7dc30a07fa5a83e252.tar.bz2
bpo-34829: Add missing selection_ methods to the Tkinter Spinbox. (GH-9617)
Implement the methods selection_from(), selection_range(), selection_present() and selection_to() for Tkinter Spinbox.
Diffstat (limited to 'Lib/tkinter/test/test_tkinter/test_widgets.py')
-rw-r--r--Lib/tkinter/test/test_tkinter/test_widgets.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/Lib/tkinter/test/test_tkinter/test_widgets.py b/Lib/tkinter/test/test_tkinter/test_widgets.py
index e4c9d33..c068a9d 100644
--- a/Lib/tkinter/test/test_tkinter/test_widgets.py
+++ b/Lib/tkinter/test/test_tkinter/test_widgets.py
@@ -377,6 +377,31 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
self.checkCommandParam(widget, 'validatecommand')
self.checkCommandParam(widget, 'vcmd')
+ def test_selection_methods(self):
+ widget = self.create()
+ widget.insert(0, '12345')
+ self.assertFalse(widget.selection_present())
+ widget.selection_range(0, 'end')
+ self.assertEqual(widget.selection_get(), '12345')
+ self.assertTrue(widget.selection_present())
+ widget.selection_from(1)
+ widget.selection_to(2)
+ self.assertEqual(widget.selection_get(), '2')
+ widget.selection_range(3, 4)
+ self.assertEqual(widget.selection_get(), '4')
+ widget.selection_clear()
+ self.assertFalse(widget.selection_present())
+ widget.selection_range(0, 'end')
+ widget.selection_adjust(4)
+ self.assertEqual(widget.selection_get(), '1234')
+ widget.selection_adjust(1)
+ self.assertEqual(widget.selection_get(), '234')
+ widget.selection_adjust(5)
+ self.assertEqual(widget.selection_get(), '2345')
+ widget.selection_adjust(0)
+ self.assertEqual(widget.selection_get(), '12345')
+ widget.selection_adjust(0)
+
@add_standard_options(StandardOptionsTests)
class SpinboxTest(EntryTest, unittest.TestCase):
@@ -474,6 +499,31 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self.assertRaises(TypeError, widget.bbox)
self.assertRaises(TypeError, widget.bbox, 0, 1)
+ def test_selection_methods(self):
+ widget = self.create()
+ widget.insert(0, '12345')
+ self.assertFalse(widget.selection_present())
+ widget.selection_range(0, 'end')
+ self.assertEqual(widget.selection_get(), '12345')
+ self.assertTrue(widget.selection_present())
+ widget.selection_from(1)
+ widget.selection_to(2)
+ self.assertEqual(widget.selection_get(), '2')
+ widget.selection_range(3, 4)
+ self.assertEqual(widget.selection_get(), '4')
+ widget.selection_clear()
+ self.assertFalse(widget.selection_present())
+ widget.selection_range(0, 'end')
+ widget.selection_adjust(4)
+ self.assertEqual(widget.selection_get(), '1234')
+ widget.selection_adjust(1)
+ self.assertEqual(widget.selection_get(), '234')
+ widget.selection_adjust(5)
+ self.assertEqual(widget.selection_get(), '2345')
+ widget.selection_adjust(0)
+ self.assertEqual(widget.selection_get(), '12345')
+ widget.selection_adjust(0)
+
@add_standard_options(StandardOptionsTests)
class TextTest(AbstractWidgetTest, unittest.TestCase):