summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test/test_pyshell.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-06 18:19:30 (GMT)
committerGitHub <noreply@github.com>2019-09-06 18:19:30 (GMT)
commit084ba337a93facac4694459b460cf329d58d2b62 (patch)
tree05b9bf652346736404bc477672e9e15342a5f3fe /Lib/idlelib/idle_test/test_pyshell.py
parent1e2707d7e82aedf73c59772bc7aa228286323c3c (diff)
downloadcpython-084ba337a93facac4694459b460cf329d58d2b62.zip
cpython-084ba337a93facac4694459b460cf329d58d2b62.tar.gz
cpython-084ba337a93facac4694459b460cf329d58d2b62.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. (cherry picked from commit 38da805d563422cf1bb9cd9be24c73806840fe30) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/idlelib/idle_test/test_pyshell.py')
-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