From a0ef40d1b577bbebaf0963ac272cd69e41bf4e16 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 20 Feb 2024 23:28:54 +0100 Subject: [PATCH] fix: datetime serialisation --- playwright/_impl/_js_handle.py | 2 +- tests/sync/test_assertions.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/playwright/_impl/_js_handle.py b/playwright/_impl/_js_handle.py index 4bd8146b1..c7b869857 100644 --- a/playwright/_impl/_js_handle.py +++ b/playwright/_impl/_js_handle.py @@ -128,7 +128,7 @@ def serialize_value( if math.isnan(value): return dict(v="NaN") if isinstance(value, datetime): - return dict(d=value.isoformat() + "Z") + return dict(d=value.isoformat()) if isinstance(value, bool): return {"b": value} if isinstance(value, (int, float)): diff --git a/tests/sync/test_assertions.py b/tests/sync/test_assertions.py index f2df44ab5..d7180fc94 100644 --- a/tests/sync/test_assertions.py +++ b/tests/sync/test_assertions.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import datetime import re -from datetime import datetime import pytest @@ -163,7 +163,11 @@ def test_assertions_locator_to_have_js_property(page: Page, server: Server) -> N ) expect(page.locator("div")).to_have_js_property( "foo", - {"a": 1, "b": "string", "c": datetime.utcfromtimestamp(1627503992000 / 1000)}, + { + "a": 1, + "b": "string", + "c": datetime.datetime.fromtimestamp(1627503992000 / 1000), + }, )