File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 8
8
from datetime import timedelta
9
9
import json
10
10
11
+ try :
12
+ from unittest import mock
13
+ except ImportError :
14
+ # py2
15
+ import mock
16
+
11
17
import nose .tools as nt
12
18
13
- from dateutil .tz import tzlocal , gettz
19
+ from dateutil .tz import tzlocal , tzoffset
14
20
from jupyter_client import jsonutil
15
21
from jupyter_client .session import utcnow
16
22
@@ -55,8 +61,11 @@ def test_parse_ms_precision():
55
61
56
62
def test_date_default ():
57
63
naive = datetime .datetime .now ()
58
- data = dict (naive = naive , utc = utcnow (), withtz = naive .replace (tzinfo = gettz ('CEST' )))
59
- jsondata = json .dumps (data , default = jsonutil .date_default )
64
+ local = tzoffset ('Local' , - 8 * 3600 )
65
+ other = tzoffset ('Other' , 2 * 3600 )
66
+ data = dict (naive = naive , utc = utcnow (), withtz = naive .replace (tzinfo = other ))
67
+ with mock .patch .object (jsonutil , 'tzlocal' , lambda : local ):
68
+ jsondata = json .dumps (data , default = jsonutil .date_default )
60
69
nt .assert_in ("Z" , jsondata )
61
70
nt .assert_equal (jsondata .count ("Z" ), 1 )
62
71
extracted = jsonutil .extract_dates (json .loads (jsondata ))
You can’t perform that action at this time.
0 commit comments