File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ def __repr__(self):
23
23
def __eq__ (self , other ):
24
24
return isinstance (other , self .__class__ ) and self .id == other .id
25
25
26
+ def __hash__ (self ):
27
+ return hash ("%s:%s" % (self .__class__ .__name__ , self .id ))
28
+
26
29
@property
27
30
def id (self ):
28
31
"""
Original file line number Diff line number Diff line change @@ -12,3 +12,17 @@ def test_reload(self):
12
12
container .reload ()
13
13
assert client .api .inspect_container .call_count == 2
14
14
assert container .attrs ['Name' ] == "foobar"
15
+
16
+ def test_hash (self ):
17
+ client = make_fake_client ()
18
+ container1 = client .containers .get (FAKE_CONTAINER_ID )
19
+ my_set = set ([container1 ])
20
+ assert len (my_set ) == 1
21
+
22
+ container2 = client .containers .get (FAKE_CONTAINER_ID )
23
+ my_set .add (container2 )
24
+ assert len (my_set ) == 1
25
+
26
+ image1 = client .images .get (FAKE_CONTAINER_ID )
27
+ my_set .add (image1 )
28
+ assert len (my_set ) == 2
You can’t perform that action at this time.
0 commit comments