mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	 ee5ef309c7
			
		
	
	
		ee5ef309c7
		
			
		
	
	
	
	
		
			
			Create a template for minimally testing a tkinter-using module by importing it and instantiating its class(es). Add a test file for all non-startup IDLE modules. Edit existing files and update coverage. This is part 1 of 3, covering the 21 autocomplete to help modules and touching 33 idlelib files.
		
			
				
	
	
		
			46 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| "Test editor, coverage 35%."
 | |
| 
 | |
| from idlelib import editor
 | |
| import unittest
 | |
| 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):
 | |
| 
 | |
|     def test_filename_to_unicode(self):
 | |
|         func = Editor._filename_to_unicode
 | |
|         class dummy():
 | |
|             filesystemencoding = 'utf-8'
 | |
|         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)
 | |
| 
 | |
| 
 | |
| if __name__ == '__main__':
 | |
|     unittest.main(verbosity=2)
 |