Skip to content

Commit fabd54d

Browse files
committed
adjust old test for orjson datetime64 fixed precision
1 parent 115d166 commit fabd54d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: packages/python/plotly/plotly/tests/test_io/test_to_from_plotly_json.py

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pandas as pd
77
import json
88
import datetime
9+
import re
910
import sys
1011
from pytz import timezone
1112
from _plotly_utils.optional_imports import get_module
@@ -201,6 +202,14 @@ def to_str(v):
201202

202203
array_str = to_json_test(dt_values)
203204
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+
204213
assert result == expected
205214
check_roundtrip(result, engine=engine, pretty=pretty)
206215

0 commit comments

Comments
 (0)