Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0ae550bd
Kaydet (Commit)
0ae550bd
authored
Eki 14, 2014
tarafından
Ethan Furman
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue22506: added methods on base Enum class now show up in dir of Enum subclass (3.4)
üst
39892055
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
enum.py
Lib/enum.py
+6
-1
test_enum.py
Lib/test/test_enum.py
+12
-0
No files found.
Lib/enum.py
Dosyayı görüntüle @
0ae550bd
...
...
@@ -464,7 +464,12 @@ class Enum(metaclass=EnumMeta):
return
"
%
s.
%
s"
%
(
self
.
__class__
.
__name__
,
self
.
_name_
)
def
__dir__
(
self
):
added_behavior
=
[
m
for
m
in
self
.
__class__
.
__dict__
if
m
[
0
]
!=
'_'
]
added_behavior
=
[
m
for
cls
in
self
.
__class__
.
mro
()
for
m
in
cls
.
__dict__
if
m
[
0
]
!=
'_'
]
return
([
'__class__'
,
'__doc__'
,
'__module__'
,
'name'
,
'value'
]
+
added_behavior
)
...
...
Lib/test/test_enum.py
Dosyayı görüntüle @
0ae550bd
...
...
@@ -176,6 +176,18 @@ class TestEnum(unittest.TestCase):
set
([
'__class__'
,
'__doc__'
,
'__module__'
,
'name'
,
'value'
,
'wowser'
]),
)
def
test_dir_on_sub_with_behavior_on_super
(
self
):
# see issue22506
class
SuperEnum
(
Enum
):
def
invisible
(
self
):
return
"did you see me?"
class
SubEnum
(
SuperEnum
):
sample
=
5
self
.
assertEqual
(
set
(
dir
(
SubEnum
.
sample
)),
set
([
'__class__'
,
'__doc__'
,
'__module__'
,
'name'
,
'value'
,
'invisible'
]),
)
def
test_enum_in_enum_out
(
self
):
Season
=
self
.
Season
self
.
assertIs
(
Season
(
Season
.
WINTER
),
Season
.
WINTER
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment