mirror of
https://github.com/python/cpython.git
synced 2025-09-30 20:31:52 +00:00
bpo-32826: Add "encoding=utf-8" to open() in idle_test/test_help_about. (GH-5639)
GUI test test_file_buttons() only looks at initial ascii-only lines,
but failed on systems where open() defaults to 'ascii' because
readline() internally reads and decodes far enough ahead to encounter
a non-ascii character in CREDITS.txt.
(cherry picked from commit f34e03ec0e
)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
parent
a1d33f7425
commit
46daf39453
2 changed files with 30 additions and 23 deletions
|
@ -50,35 +50,37 @@ class LiveDialogTest(unittest.TestCase):
|
||||||
def test_printer_buttons(self):
|
def test_printer_buttons(self):
|
||||||
"""Test buttons whose commands use printer function."""
|
"""Test buttons whose commands use printer function."""
|
||||||
dialog = self.dialog
|
dialog = self.dialog
|
||||||
button_sources = [(dialog.py_license, license),
|
button_sources = [(dialog.py_license, license, 'license'),
|
||||||
(dialog.py_copyright, copyright),
|
(dialog.py_copyright, copyright, 'copyright'),
|
||||||
(dialog.py_credits, credits)]
|
(dialog.py_credits, credits, 'credits')]
|
||||||
|
|
||||||
for button, printer in button_sources:
|
for button, printer, name in button_sources:
|
||||||
printer._Printer__setup()
|
with self.subTest(name=name):
|
||||||
button.invoke()
|
printer._Printer__setup()
|
||||||
get = dialog._current_textview.viewframe.textframe.text.get
|
button.invoke()
|
||||||
self.assertEqual(printer._Printer__lines[0], get('1.0', '1.end'))
|
get = dialog._current_textview.viewframe.textframe.text.get
|
||||||
self.assertEqual(
|
lines = printer._Printer__lines
|
||||||
printer._Printer__lines[1], get('2.0', '2.end'))
|
self.assertEqual(lines[0], get('1.0', '1.end'))
|
||||||
dialog._current_textview.destroy()
|
self.assertEqual(lines[1], get('2.0', '2.end'))
|
||||||
|
dialog._current_textview.destroy()
|
||||||
|
|
||||||
def test_file_buttons(self):
|
def test_file_buttons(self):
|
||||||
"""Test buttons that display files."""
|
"""Test buttons that display files."""
|
||||||
dialog = self.dialog
|
dialog = self.dialog
|
||||||
button_sources = [(self.dialog.readme, 'README.txt'),
|
button_sources = [(self.dialog.readme, 'README.txt', 'readme'),
|
||||||
(self.dialog.idle_news, 'NEWS.txt'),
|
(self.dialog.idle_news, 'NEWS.txt', 'news'),
|
||||||
(self.dialog.idle_credits, 'CREDITS.txt')]
|
(self.dialog.idle_credits, 'CREDITS.txt', 'credits')]
|
||||||
|
|
||||||
for button, filename in button_sources:
|
for button, filename, name in button_sources:
|
||||||
button.invoke()
|
with self.subTest(name=name):
|
||||||
fn = findfile(filename, subdir='idlelib')
|
button.invoke()
|
||||||
get = dialog._current_textview.viewframe.textframe.text.get
|
fn = findfile(filename, subdir='idlelib')
|
||||||
with open(fn) as f:
|
get = dialog._current_textview.viewframe.textframe.text.get
|
||||||
self.assertEqual(f.readline().strip(), get('1.0', '1.end'))
|
with open(fn, encoding='utf-8') as f:
|
||||||
f.readline()
|
self.assertEqual(f.readline().strip(), get('1.0', '1.end'))
|
||||||
self.assertEqual(f.readline().strip(), get('3.0', '3.end'))
|
f.readline()
|
||||||
dialog._current_textview.destroy()
|
self.assertEqual(f.readline().strip(), get('3.0', '3.end'))
|
||||||
|
dialog._current_textview.destroy()
|
||||||
|
|
||||||
|
|
||||||
class DefaultTitleTest(unittest.TestCase):
|
class DefaultTitleTest(unittest.TestCase):
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
Add "encoding=utf-8" to open() in IDLE's test_help_about.
|
||||||
|
GUI test test_file_buttons() only looks at initial ascii-only lines,
|
||||||
|
but failed on systems where open() defaults to 'ascii' because
|
||||||
|
readline() internally reads and decodes far enough ahead to encounter
|
||||||
|
a non-ascii character in CREDITS.txt.
|
Loading…
Add table
Add a link
Reference in a new issue