mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-26353: IDLE adds an unneeded newline when saving a shell window (GH-17103)
This commit is contained in:
parent
733b9a308e
commit
c8b53dc3d8
4 changed files with 33 additions and 15 deletions
|
@ -1,14 +1,13 @@
|
|||
"Test , coverage 16%."
|
||||
"Test , coverage 17%."
|
||||
|
||||
from idlelib import iomenu
|
||||
import unittest
|
||||
from test.support import requires
|
||||
from tkinter import Tk
|
||||
|
||||
from idlelib.editor import EditorWindow
|
||||
|
||||
|
||||
class IOBindigTest(unittest.TestCase):
|
||||
class IOBindingTest(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -16,9 +15,11 @@ class IOBindigTest(unittest.TestCase):
|
|||
cls.root = Tk()
|
||||
cls.root.withdraw()
|
||||
cls.editwin = EditorWindow(root=cls.root)
|
||||
cls.io = iomenu.IOBinding(cls.editwin)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.io.close()
|
||||
cls.editwin._close()
|
||||
del cls.editwin
|
||||
cls.root.update_idletasks()
|
||||
|
@ -28,9 +29,20 @@ class IOBindigTest(unittest.TestCase):
|
|||
del cls.root
|
||||
|
||||
def test_init(self):
|
||||
io = iomenu.IOBinding(self.editwin)
|
||||
self.assertIs(io.editwin, self.editwin)
|
||||
io.close
|
||||
self.assertIs(self.io.editwin, self.editwin)
|
||||
|
||||
def test_fixnewlines_end(self):
|
||||
eq = self.assertEqual
|
||||
io = self.io
|
||||
fix = io.fixnewlines
|
||||
text = io.editwin.text
|
||||
self.editwin.interp = None
|
||||
eq(fix(), '')
|
||||
del self.editwin.interp
|
||||
text.insert(1.0, 'a')
|
||||
eq(fix(), 'a'+io.eol_convention)
|
||||
eq(text.get('1.0', 'end-1c'), 'a\n')
|
||||
eq(fix(), 'a'+io.eol_convention)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue