mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-42759: Fix equality comparison of Variable and Font in Tkinter (GH-23968)
Objects which belong to different Tcl interpreters are now always
different, even if they have the same name.
(cherry picked from commit 1df56bc059)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									7bdb3e0825
								
							
						
					
					
						commit
						578caafabe
					
				
					 5 changed files with 27 additions and 11 deletions
				
			
		|  | @ -58,22 +58,32 @@ def test_dont_unset_not_existing(self): | |||
|         del v2 | ||||
|         self.assertFalse(self.info_exists("name")) | ||||
| 
 | ||||
|     def test___eq__(self): | ||||
|     def test_equality(self): | ||||
|         # values doesn't matter, only class and name are checked | ||||
|         v1 = Variable(self.root, name="abc") | ||||
|         v2 = Variable(self.root, name="abc") | ||||
|         self.assertIsNot(v1, v2) | ||||
|         self.assertEqual(v1, v2) | ||||
| 
 | ||||
|         v3 = StringVar(self.root, name="abc") | ||||
|         v3 = Variable(self.root, name="cba") | ||||
|         self.assertNotEqual(v1, v3) | ||||
| 
 | ||||
|         v4 = StringVar(self.root, name="abc") | ||||
|         self.assertEqual(str(v1), str(v4)) | ||||
|         self.assertNotEqual(v1, v4) | ||||
| 
 | ||||
|         V = type('Variable', (), {}) | ||||
|         self.assertNotEqual(v1, V()) | ||||
| 
 | ||||
|         self.assertNotEqual(v1, object()) | ||||
|         self.assertEqual(v1, ALWAYS_EQ) | ||||
| 
 | ||||
|         root2 = tkinter.Tk() | ||||
|         self.addCleanup(root2.destroy) | ||||
|         v5 = Variable(root2, name="abc") | ||||
|         self.assertEqual(str(v1), str(v5)) | ||||
|         self.assertNotEqual(v1, v5) | ||||
| 
 | ||||
|     def test_invalid_name(self): | ||||
|         with self.assertRaises(TypeError): | ||||
|             Variable(self.root, name=123) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)