File tree 1 file changed +9
-0
lines changed
packages/python/plotly/plotly/tests/test_io
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 6
6
import pandas as pd
7
7
import json
8
8
import datetime
9
+ import re
9
10
import sys
10
11
from pytz import timezone
11
12
from _plotly_utils .optional_imports import get_module
@@ -201,6 +202,14 @@ def to_str(v):
201
202
202
203
array_str = to_json_test (dt_values )
203
204
expected = build_test_dict_string (array_str )
205
+ if orjson :
206
+ # orjson always serializes datetime64 to ns, but json will return either
207
+ # full seconds or microseconds, if the rest is zeros.
208
+ # we don't care about any trailing zeros
209
+ trailing_zeros = re .compile (r'[.]?0+"' )
210
+ result = trailing_zeros .sub ('"' , result )
211
+ expected = trailing_zeros .sub ('"' , expected )
212
+
204
213
assert result == expected
205
214
check_roundtrip (result , engine = engine , pretty = pretty )
206
215
You can’t perform that action at this time.
0 commit comments