summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2019-09-06 17:54:45 (GMT)
committerGitHub <noreply@github.com>2019-09-06 17:54:45 (GMT)
commit38da805d563422cf1bb9cd9be24c73806840fe30 (patch)
treef23132ee1104b4586d25cb4b051716671ecb855a /Lib/idlelib/idle_test
parent74b662cf202753d224d82d5503974cce881f7436 (diff)
downloadcpython-38da805d563422cf1bb9cd9be24c73806840fe30.zip
cpython-38da805d563422cf1bb9cd9be24c73806840fe30.tar.gz
cpython-38da805d563422cf1bb9cd9be24c73806840fe30.tar.bz2
bpo-38041: Refine IDLE Shell restart lines. (GH-15709)
Restart lines now always start with '=' and never end with ' ' and fill the width of the window unless that would require ending with ' ', which could be wrapped by itself and possible confusing the user.
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r--Lib/idlelib/idle_test/test_pyshell.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/idlelib/idle_test/test_pyshell.py b/Lib/idlelib/idle_test/test_pyshell.py
index 581444c..4a09667 100644
--- a/Lib/idlelib/idle_test/test_pyshell.py
+++ b/Lib/idlelib/idle_test/test_pyshell.py
@@ -7,6 +7,28 @@ from test.support import requires
from tkinter import Tk
+class FunctionTest(unittest.TestCase):
+ # Test stand-alone module level non-gui functions.
+
+ def test_restart_line_wide(self):
+ eq = self.assertEqual
+ for file, mul, extra in (('', 22, ''), ('finame', 21, '=')):
+ width = 60
+ bar = mul * '='
+ with self.subTest(file=file, bar=bar):
+ file = file or 'Shell'
+ line = pyshell.restart_line(width, file)
+ eq(len(line), width)
+ eq(line, f"{bar+extra} RESTART: {file} {bar}")
+
+ def test_restart_line_narrow(self):
+ expect, taglen = "= RESTART: Shell", 16
+ for width in (taglen-1, taglen, taglen+1):
+ with self.subTest(width=width):
+ self.assertEqual(pyshell.restart_line(width, ''), expect)
+ self.assertEqual(pyshell.restart_line(taglen+2, ''), expect+' =')
+
+
class PyShellFileListTest(unittest.TestCase):
@classmethod