Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
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
docker-py
Commits
6f239fbf
Kaydet (Commit)
6f239fbf
authored
Ara 08, 2016
tarafından
Flavio Curella
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make resources hashable, so that they can be added to `set`s
Signed-off-by:
Flavio Curella
<
flavio.curella@gmail.com
>
üst
d024b1bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
resource.py
docker/models/resource.py
+3
-0
models_resources_test.py
tests/unit/models_resources_test.py
+14
-0
No files found.
docker/models/resource.py
Dosyayı görüntüle @
6f239fbf
...
...
@@ -23,6 +23,9 @@ class Model(object):
def
__eq__
(
self
,
other
):
return
isinstance
(
other
,
self
.
__class__
)
and
self
.
id
==
other
.
id
def
__hash__
(
self
):
return
hash
(
"
%
s:
%
s"
%
(
self
.
__class__
.
__name__
,
self
.
id
))
@property
def
id
(
self
):
"""
...
...
tests/unit/models_resources_test.py
Dosyayı görüntüle @
6f239fbf
...
...
@@ -12,3 +12,17 @@ class ModelTest(unittest.TestCase):
container
.
reload
()
assert
client
.
api
.
inspect_container
.
call_count
==
2
assert
container
.
attrs
[
'Name'
]
==
"foobar"
def
test_hash
(
self
):
client
=
make_fake_client
()
container1
=
client
.
containers
.
get
(
FAKE_CONTAINER_ID
)
my_set
=
set
([
container1
])
assert
len
(
my_set
)
==
1
container2
=
client
.
containers
.
get
(
FAKE_CONTAINER_ID
)
my_set
.
add
(
container2
)
assert
len
(
my_set
)
==
1
image1
=
client
.
images
.
get
(
FAKE_CONTAINER_ID
)
my_set
.
add
(
image1
)
assert
len
(
my_set
)
==
2
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