Skip to content

Commit

Permalink
fix: datetime serialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Feb 20, 2024
1 parent 516bdad commit a0ef40d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion playwright/_impl/_js_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
8 changes: 6 additions & 2 deletions tests/sync/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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),
},
)


Expand Down

0 comments on commit a0ef40d

Please sign in to comment.