Skip to content

Commit

Permalink
chore(tests): fixes for lower python versions
Browse files Browse the repository at this point in the history
Signed-off-by: JP-Ellis <[email protected]>
  • Loading branch information
JP-Ellis committed Mar 22, 2024
1 parent cd4585e commit f6f8074
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/v3/compatibility_suite/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ def serialize(obj: Any) -> Any: # noqa: ANN401, PLR0911
All other types are converted to strings using the `repr` function.
"""
if isinstance(obj, datetime | date | time):
if isinstance(obj, (datetime, date, time)):
return obj.isoformat()

# Basic types which are already serializable
if isinstance(obj, str | int | float | bool | type(None)):
if isinstance(obj, (str, int, float, bool, type(None))):
return obj

# Bytes
Expand Down
9 changes: 8 additions & 1 deletion tests/v3/compatibility_suite/util/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import socket
import subprocess
from contextvars import ContextVar
from datetime import UTC, datetime
from datetime import datetime
from pathlib import Path
from typing import TYPE_CHECKING

Expand All @@ -38,6 +38,13 @@
if TYPE_CHECKING:
from tests.v3.compatibility_suite.util import InteractionDefinition

if sys.version_info < (3, 11):
from datetime import timezone

UTC = timezone.utc
else:
from datetime import UTC


logger = logging.getLogger(__name__)

Expand Down

0 comments on commit f6f8074

Please sign in to comment.