mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	gh-71339: Use new assertion methods in test_idle (#129213)
Revise 10 tests in 7 files, with 1 test split into 2.
This commit is contained in:
		
							parent
							
								
									c05a851ac5
								
							
						
					
					
						commit
						dbb25ce037
					
				
					 7 changed files with 11 additions and 11 deletions
				
			
		|  | @ -98,8 +98,8 @@ def test_click_help(self): | ||||||
|             dialog.buttons['Help'].invoke() |             dialog.buttons['Help'].invoke() | ||||||
|             title, contents = view.kwds['title'], view.kwds['contents'] |             title, contents = view.kwds['title'], view.kwds['contents'] | ||||||
|         self.assertEqual(title, 'Help for IDLE preferences') |         self.assertEqual(title, 'Help for IDLE preferences') | ||||||
|         self.assertTrue(contents.startswith('When you click') and |         self.assertStartsWith(contents, 'When you click') | ||||||
|                         contents.endswith('a different name.\n')) |         self.assertEndsWith(contents,'a different name.\n') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class FontPageTest(unittest.TestCase): | class FontPageTest(unittest.TestCase): | ||||||
|  |  | ||||||
|  | @ -256,7 +256,7 @@ def test_init(self): | ||||||
|         flist = None |         flist = None | ||||||
|         master_window = self.root |         master_window = self.root | ||||||
|         sv = debugger.StackViewer(master_window, flist, gui) |         sv = debugger.StackViewer(master_window, flist, gui) | ||||||
|         self.assertTrue(hasattr(sv, 'stack')) |         self.assertHasAttr(sv, 'stack') | ||||||
| 
 | 
 | ||||||
|     def test_load_stack(self): |     def test_load_stack(self): | ||||||
|         # Test the .load_stack() method against a fixed test stack. |         # Test the .load_stack() method against a fixed test stack. | ||||||
|  |  | ||||||
|  | @ -143,7 +143,7 @@ def test_found(self): | ||||||
|         self.assertIn(pat, lines[0]) |         self.assertIn(pat, lines[0]) | ||||||
|         self.assertIn('py: 1:', lines[1])  # line number 1 |         self.assertIn('py: 1:', lines[1])  # line number 1 | ||||||
|         self.assertIn('2', lines[3])  # hits found 2 |         self.assertIn('2', lines[3])  # hits found 2 | ||||||
|         self.assertTrue(lines[4].startswith('(Hint:')) |         self.assertStartsWith(lines[4], '(Hint:') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Default_commandTest(unittest.TestCase): | class Default_commandTest(unittest.TestCase): | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ def tearDownClass(cls): | ||||||
|     def test_creator(self): |     def test_creator(self): | ||||||
|         mc = self.mc |         mc = self.mc | ||||||
|         self.assertIs(multicall._multicall_dict[Text], mc) |         self.assertIs(multicall._multicall_dict[Text], mc) | ||||||
|         self.assertTrue(issubclass(mc, Text)) |         self.assertIsSubclass(mc, Text) | ||||||
|         mc2 = multicall.MultiCallCreator(Text) |         mc2 = multicall.MultiCallCreator(Text) | ||||||
|         self.assertIs(mc, mc2) |         self.assertIs(mc, mc2) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -134,10 +134,10 @@ def test_c_source_name(self): | ||||||
| 
 | 
 | ||||||
|     def test_good_module_name(self): |     def test_good_module_name(self): | ||||||
|         dialog = self.Dummy_ModuleName('idlelib') |         dialog = self.Dummy_ModuleName('idlelib') | ||||||
|         self.assertTrue(dialog.entry_ok().endswith('__init__.py')) |         self.assertEndsWith(dialog.entry_ok(), '__init__.py') | ||||||
|         self.assertEqual(dialog.entry_error['text'], '') |         self.assertEqual(dialog.entry_error['text'], '') | ||||||
|         dialog = self.Dummy_ModuleName('idlelib.idle') |         dialog = self.Dummy_ModuleName('idlelib.idle') | ||||||
|         self.assertTrue(dialog.entry_ok().endswith('idle.py')) |         self.assertEndsWith(dialog.entry_ok(), 'idle.py') | ||||||
|         self.assertEqual(dialog.entry_error['text'], '') |         self.assertEqual(dialog.entry_error['text'], '') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -389,7 +389,7 @@ def test_click_module_name(self): | ||||||
|         self.assertEqual(dialog.text0, 'idlelib') |         self.assertEqual(dialog.text0, 'idlelib') | ||||||
|         self.assertEqual(dialog.entry.get(), 'idlelib') |         self.assertEqual(dialog.entry.get(), 'idlelib') | ||||||
|         dialog.button_ok.invoke() |         dialog.button_ok.invoke() | ||||||
|         self.assertTrue(dialog.result.endswith('__init__.py')) |         self.assertEndsWith(dialog.result, '__init__.py') | ||||||
|         root.destroy() |         root.destroy() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ def test_close(self): | ||||||
|         redir.register('insert', Func) |         redir.register('insert', Func) | ||||||
|         redir.close() |         redir.close() | ||||||
|         self.assertEqual(redir._operations, {}) |         self.assertEqual(redir._operations, {}) | ||||||
|         self.assertFalse(hasattr(self.text, 'widget')) |         self.assertNotHasAttr(self.text, 'widget') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class WidgetRedirectorTest(unittest.TestCase): | class WidgetRedirectorTest(unittest.TestCase): | ||||||
|  |  | ||||||
|  | @ -725,7 +725,7 @@ def test_copy(self): | ||||||
| 
 | 
 | ||||||
|         text.tag_add('sel', f'{first_line}.0', 'end-1c') |         text.tag_add('sel', f'{first_line}.0', 'end-1c') | ||||||
|         selected_text = text.get('sel.first', 'sel.last') |         selected_text = text.get('sel.first', 'sel.last') | ||||||
|         self.assertTrue(selected_text.startswith('if True:\n')) |         self.assertStartsWith(selected_text, 'if True:\n') | ||||||
|         self.assertIn('\n1\n', selected_text) |         self.assertIn('\n1\n', selected_text) | ||||||
| 
 | 
 | ||||||
|         text.event_generate('<<copy>>') |         text.event_generate('<<copy>>') | ||||||
|  | @ -749,7 +749,7 @@ def test_copy_with_prompts(self): | ||||||
| 
 | 
 | ||||||
|         text.tag_add('sel', f'{first_line}.3', 'end-1c') |         text.tag_add('sel', f'{first_line}.3', 'end-1c') | ||||||
|         selected_text = text.get('sel.first', 'sel.last') |         selected_text = text.get('sel.first', 'sel.last') | ||||||
|         self.assertTrue(selected_text.startswith('True:\n')) |         self.assertStartsWith(selected_text, 'True:\n') | ||||||
| 
 | 
 | ||||||
|         selected_lines_text = text.get('sel.first linestart', 'sel.last') |         selected_lines_text = text.get('sel.first linestart', 'sel.last') | ||||||
|         selected_lines = selected_lines_text.split('\n') |         selected_lines = selected_lines_text.split('\n') | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Terry Jan Reedy
						Terry Jan Reedy