From 665af8dbe9f188c1dd5d1913d16e4d709a0dd9cc Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 5 Mar 2024 20:52:34 +0100 Subject: [PATCH] Revert "fix: datetime serialisation (#2314)" This reverts commit c4ffd453c124fb491bb6a2cdc9899ba448eb909d. --- playwright/_impl/_js_handle.py | 2 +- tests/sync/test_assertions.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/playwright/_impl/_js_handle.py b/playwright/_impl/_js_handle.py index 01625ec3f..5a930f1e6 100644 --- a/playwright/_impl/_js_handle.py +++ b/playwright/_impl/_js_handle.py @@ -129,7 +129,7 @@ def serialize_value( if math.isnan(value): return dict(v="NaN") if isinstance(value, datetime): - return dict(d=value.isoformat()) + return dict(d=value.isoformat() + "Z") 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 d7180fc94..f2df44ab5 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,11 +163,7 @@ 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.datetime.fromtimestamp(1627503992000 / 1000), - }, + {"a": 1, "b": "string", "c": datetime.utcfromtimestamp(1627503992000 / 1000)}, )