summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enum.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-12-14 22:43:43 (GMT)
committerGitHub <noreply@github.com>2020-12-14 22:43:43 (GMT)
commit33cbb04986d0dabb9c542edc52bb4ea6106d3a81 (patch)
tree05c1054839b07b835f57da2d6a984aa85273d716 /Lib/test/test_enum.py
parentdbb00062dc3afb12c41c87564e6faefe60766b01 (diff)
downloadcpython-33cbb04986d0dabb9c542edc52bb4ea6106d3a81.zip
cpython-33cbb04986d0dabb9c542edc52bb4ea6106d3a81.tar.gz
cpython-33cbb04986d0dabb9c542edc52bb4ea6106d3a81.tar.bz2
bpo-40084: Enum - dir() includes member attributes (GH-19219)
(cherry picked from commit 68526fe258da8c01196fd7cf48e8e5f1280bf8fd) Co-authored-by: Angelin BOOZ <9497359+lem2clide@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_enum.py')
-rw-r--r--Lib/test/test_enum.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index ccc2cbe..dca668a 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -215,6 +215,18 @@ class TestEnum(unittest.TestCase):
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)