File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 28
28
from .. import errors
29
29
from .. import tls
30
30
31
+
31
32
DEFAULT_HTTP_HOST = "127.0.0.1"
32
33
DEFAULT_UNIX_SOCKET = "http+unix://var/run/docker.sock"
33
34
@@ -299,7 +300,8 @@ def convert_filters(filters):
299
300
300
301
def datetime_to_timestamp (dt = datetime .now ()):
301
302
"""Convert a datetime in local timezone to a unix timestamp"""
302
- return int ((dt - datetime .fromtimestamp (0 )).total_seconds ())
303
+ delta = dt - datetime .fromtimestamp (0 )
304
+ return delta .seconds + delta .days * 24 * 3600
303
305
304
306
305
307
def create_host_config (
Original file line number Diff line number Diff line change @@ -190,10 +190,10 @@ def test_events(self):
190
190
)
191
191
192
192
def test_events_with_since_until (self ):
193
- now = datetime .datetime .now ()
193
+ ts = 1356048000
194
+ now = datetime .datetime .fromtimestamp (ts )
194
195
since = now - datetime .timedelta (seconds = 10 )
195
196
until = now + datetime .timedelta (seconds = 10 )
196
- ts = int ((now - datetime .datetime .fromtimestamp (0 )).total_seconds ())
197
197
try :
198
198
self .client .events (since = since , until = until )
199
199
except Exception as e :
@@ -210,7 +210,8 @@ def test_events_with_since_until(self):
210
210
)
211
211
212
212
def test_events_with_filters (self ):
213
- filters = {'event' : ['die' , 'stop' ], 'container' : fake_api .FAKE_CONTAINER_ID }
213
+ filters = {'event' : ['die' , 'stop' ],
214
+ 'container' : fake_api .FAKE_CONTAINER_ID }
214
215
try :
215
216
self .client .events (filters = filters )
216
217
except Exception as e :
You can’t perform that action at this time.
0 commit comments