##// END OF EJS Templates
don't depend on utils.tz in test_jsonutil...
Min RK -
Show More
@@ -10,7 +10,7 b' from base64 import decodestring'
10
10
11 import nose.tools as nt
11 import nose.tools as nt
12
12
13 from jupyter_client import jsonutil, tz
13 from jupyter_client import jsonutil
14 from ..jsonutil import json_clean, encode_images
14 from ..jsonutil import json_clean, encode_images
15 from IPython.utils.py3compat import unicode_to_str, str_to_bytes, iteritems
15 from IPython.utils.py3compat import unicode_to_str, str_to_bytes, iteritems
16
16
@@ -129,8 +129,24 b' def test_parse_ms_precision():'
129 else:
129 else:
130 nt.assert_is_instance(parsed, str)
130 nt.assert_is_instance(parsed, str)
131
131
132
133 ZERO = datetime.timedelta(0)
134
135 class tzUTC(datetime.tzinfo):
136 """tzinfo object for UTC (zero offset)"""
137
138 def utcoffset(self, d):
139 return ZERO
140
141 def dst(self, d):
142 return ZERO
143
144 UTC = tzUTC()
145
132 def test_date_default():
146 def test_date_default():
133 data = dict(today=datetime.datetime.now(), utcnow=tz.utcnow())
147 now = today=datetime.datetime.now()
148 utcnow = now.replace(tzinfo=UTC)
149 data = dict(now=now, utcnow=utcnow)
134 jsondata = json.dumps(data, default=jsonutil.date_default)
150 jsondata = json.dumps(data, default=jsonutil.date_default)
135 nt.assert_in("+00", jsondata)
151 nt.assert_in("+00", jsondata)
136 nt.assert_equal(jsondata.count("+00"), 1)
152 nt.assert_equal(jsondata.count("+00"), 1)
General Comments 0
You need to be logged in to leave comments. Login now