mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Close #18693: Enum is now more help() friendly.
This commit is contained in:
parent
173a157e72
commit
c850f34220
2 changed files with 25 additions and 4 deletions
|
@ -98,7 +98,7 @@ class TestEnum(unittest.TestCase):
|
|||
Season = self.Season
|
||||
self.assertEqual(
|
||||
set(dir(Season)),
|
||||
set(['__class__', '__doc__', '__members__',
|
||||
set(['__class__', '__doc__', '__members__', '__module__',
|
||||
'SPRING', 'SUMMER', 'AUTUMN', 'WINTER']),
|
||||
)
|
||||
|
||||
|
@ -106,9 +106,24 @@ class TestEnum(unittest.TestCase):
|
|||
Season = self.Season
|
||||
self.assertEqual(
|
||||
set(dir(Season.WINTER)),
|
||||
set(['__class__', '__doc__', 'name', 'value']),
|
||||
set(['__class__', '__doc__', '__module__', 'name', 'value']),
|
||||
)
|
||||
|
||||
def test_dir_with_added_behavior(self):
|
||||
class Test(Enum):
|
||||
this = 'that'
|
||||
these = 'those'
|
||||
def wowser(self):
|
||||
return ("Wowser! I'm %s!" % self.name)
|
||||
self.assertEqual(
|
||||
set(dir(Test)),
|
||||
set(['__class__', '__doc__', '__members__', '__module__', 'this', 'these']),
|
||||
)
|
||||
self.assertEqual(
|
||||
set(dir(Test.this)),
|
||||
set(['__class__', '__doc__', '__module__', 'name', 'value', 'wowser']),
|
||||
)
|
||||
|
||||
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