2018-06-15 19:20:55 -03:00
|
|
|
"Test editor, coverage 35%."
|
|
|
|
|
|
|
|
from idlelib import editor
|
2015-08-06 01:54:07 -03:00
|
|
|
import unittest
|
2018-06-15 19:20:55 -03:00
|
|
|
from test.support import requires
|
|
|
|
from tkinter import Tk
|
|
|
|
|
|
|
|
Editor = editor.EditorWindow
|
|
|
|
|
|
|
|
|
|
|
|
class EditorWindowTest(unittest.TestCase):
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
requires('gui')
|
|
|
|
cls.root = Tk()
|
|
|
|
cls.root.withdraw()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
cls.root.update_idletasks()
|
|
|
|
for id in cls.root.tk.call('after', 'info'):
|
|
|
|
cls.root.after_cancel(id)
|
|
|
|
cls.root.destroy()
|
|
|
|
del cls.root
|
|
|
|
|
|
|
|
def test_init(self):
|
|
|
|
e = Editor(root=self.root)
|
|
|
|
self.assertEqual(e.root, self.root)
|
|
|
|
e._close()
|
|
|
|
|
|
|
|
|
|
|
|
class EditorFunctionTest(unittest.TestCase):
|
2015-08-06 01:54:07 -03:00
|
|
|
|
|
|
|
def test_filename_to_unicode(self):
|
2018-06-15 19:20:55 -03:00
|
|
|
func = Editor._filename_to_unicode
|
|
|
|
class dummy():
|
|
|
|
filesystemencoding = 'utf-8'
|
2015-08-06 01:54:07 -03:00
|
|
|
pairs = (('abc', 'abc'), ('a\U00011111c', 'a\ufffdc'),
|
|
|
|
(b'abc', 'abc'), (b'a\xf0\x91\x84\x91c', 'a\ufffdc'))
|
|
|
|
for inp, out in pairs:
|
|
|
|
self.assertEqual(func(dummy, inp), out)
|
|
|
|
|
2018-06-15 19:20:55 -03:00
|
|
|
|
2015-08-06 01:54:07 -03:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(verbosity=2)
|