summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-07-27 17:19:12 (GMT)
committerGitHub <noreply@github.com>2019-07-27 17:19:12 (GMT)
commit171019354aa2c717af2e7b2c90aec7b9724f7282 (patch)
tree45423e0d0b45f6897ae029ec4cbe177b6ef71b65 /Lib/idlelib/idle_test
parentd38fa5869502dcd00343978bdf6b726035415ddb (diff)
downloadcpython-171019354aa2c717af2e7b2c90aec7b9724f7282.zip
cpython-171019354aa2c717af2e7b2c90aec7b9724f7282.tar.gz
cpython-171019354aa2c717af2e7b2c90aec7b9724f7282.tar.bz2
bpo-37628: Fix IDLE config sample sizes (GH-14958)
The boxes for the font and highlight samples are now constrained by the overall config dialog size. They gain scrollbars when the when a large font size makes the samples too large for the box. (cherry picked from commit 3221a63c69268a9362802371a616f49d522a5c4f) Co-authored-by: Tal Einat <taleinat+github@gmail.com>
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r--Lib/idlelib/idle_test/htest.py2
-rw-r--r--Lib/idlelib/idle_test/test_textview.py60
2 files changed, 57 insertions, 5 deletions
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py
index f2f37e1..6990af5 100644
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -349,7 +349,7 @@ _undo_delegator_spec = {
ViewWindow_spec = {
'file': 'textview',
'kwds': {'title': 'Test textview',
- 'text': 'The quick brown fox jumps over the lazy dog.\n'*35,
+ 'contents': 'The quick brown fox jumps over the lazy dog.\n'*35,
'_htest': True},
'msg': "Test for read-only property of text.\n"
"Select text, scroll window, close"
diff --git a/Lib/idlelib/idle_test/test_textview.py b/Lib/idlelib/idle_test/test_textview.py
index 6f0c193..7189378 100644
--- a/Lib/idlelib/idle_test/test_textview.py
+++ b/Lib/idlelib/idle_test/test_textview.py
@@ -6,12 +6,12 @@ Using mock Text would not change this. Other mocks are used to retrieve
information about calls.
"""
from idlelib import textview as tv
-import unittest
from test.support import requires
requires('gui')
import os
-from tkinter import Tk
+import unittest
+from tkinter import Tk, TclError, CHAR, NONE, WORD
from tkinter.ttk import Button
from idlelib.idle_test.mock_idle import Func
from idlelib.idle_test.mock_tk import Mbox_func
@@ -69,13 +69,65 @@ class ViewWindowTest(unittest.TestCase):
view.destroy()
-class TextFrameTest(unittest.TestCase):
+class AutoHideScrollbarTest(unittest.TestCase):
+ # Method set is tested in ScrollableTextFrameTest
+ def test_forbidden_geometry(self):
+ scroll = tv.AutoHideScrollbar(root)
+ self.assertRaises(TclError, scroll.pack)
+ self.assertRaises(TclError, scroll.place)
+
+
+class ScrollableTextFrameTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.root = root = Tk()
+ root.withdraw()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.root.update_idletasks()
+ cls.root.destroy()
+ del cls.root
+
+ def make_frame(self, wrap=NONE, **kwargs):
+ frame = tv.ScrollableTextFrame(self.root, wrap=wrap, **kwargs)
+ def cleanup_frame():
+ frame.update_idletasks()
+ frame.destroy()
+ self.addCleanup(cleanup_frame)
+ return frame
+
+ def test_line1(self):
+ frame = self.make_frame()
+ frame.text.insert('1.0', 'test text')
+ self.assertEqual(frame.text.get('1.0', '1.end'), 'test text')
+
+ def test_horiz_scrollbar(self):
+ # The horizontal scrollbar should be shown/hidden according to
+ # the 'wrap' setting: It should only be shown when 'wrap' is
+ # set to NONE.
+
+ # wrap = NONE -> with horizontal scrolling
+ frame = self.make_frame(wrap=NONE)
+ self.assertEqual(frame.text.cget('wrap'), NONE)
+ self.assertIsNotNone(frame.xscroll)
+
+ # wrap != NONE -> no horizontal scrolling
+ for wrap in [CHAR, WORD]:
+ with self.subTest(wrap=wrap):
+ frame = self.make_frame(wrap=wrap)
+ self.assertEqual(frame.text.cget('wrap'), wrap)
+ self.assertIsNone(frame.xscroll)
+
+
+class ViewFrameTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.root = root = Tk()
root.withdraw()
- cls.frame = tv.TextFrame(root, 'test text')
+ cls.frame = tv.ViewFrame(root, 'test text')
@classmethod
def tearDownClass(cls):