mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-40084: Enum - dir() includes member attributes (GH-19219)
(cherry picked from commit 68526fe258)
Co-authored-by: Angelin BOOZ <9497359+lem2clide@users.noreply.github.com>
			
			
This commit is contained in:
		
							parent
							
								
									dbb00062dc
								
							
						
					
					
						commit
						33cbb04986
					
				
					 5 changed files with 20 additions and 2 deletions
				
			
		|  | @ -215,6 +215,18 @@ class SubEnum(SuperEnum): | |||
|                 set(['__class__', '__doc__', '__module__', 'name', 'value', 'invisible']), | ||||
|                 ) | ||||
| 
 | ||||
|     def test_dir_on_sub_with_behavior_including_instance_dict_on_super(self): | ||||
|         # see issue40084 | ||||
|         class SuperEnum(IntEnum): | ||||
|             def __new__(cls, value, description=""): | ||||
|                 obj = int.__new__(cls, value) | ||||
|                 obj._value_ = value | ||||
|                 obj.description = description | ||||
|                 return obj | ||||
|         class SubEnum(SuperEnum): | ||||
|             sample = 5 | ||||
|         self.assertTrue({'description'} <= set(dir(SubEnum.sample))) | ||||
| 
 | ||||
|     def test_enum_in_enum_out(self): | ||||
|         Season = self.Season | ||||
|         self.assertIs(Season(Season.WINTER), Season.WINTER) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)