From 455e6ceb6bad75b76b033495087ef89a7893c460 Mon Sep 17 00:00:00 2001 From: Tom Tang Date: Thu, 30 Mar 2023 00:03:35 +0000 Subject: [PATCH] test(datetime): printable conversion through ISO8601 string --- tests/python/test_pythonmonkey_eval.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/python/test_pythonmonkey_eval.py b/tests/python/test_pythonmonkey_eval.py index 3ef36c25..5ac72a30 100644 --- a/tests/python/test_pythonmonkey_eval.py +++ b/tests/python/test_pythonmonkey_eval.py @@ -180,8 +180,9 @@ def test_eval_dates(): end = start + timedelta(days=365 * years) for _ in range(10): py_date = start + (end - start) * random.random() - py_date = py_date.replace(microsecond=0) - js_date = pm.eval(f'new Date({py_date.year}, {py_date.month - 1}, {py_date.day}, {py_date.hour}, {py_date.minute}, {py_date.second}, {py_date.microsecond / 1000})') + # round to milliseconds precision because the smallest unit for js Date is 1ms + py_date = py_date.replace(microsecond=round(py_date.microsecond, -3)) + js_date = pm.eval(f'new Date("{py_date.isoformat()}")') assert py_date == js_date def test_eval_boxed_booleans():