mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-16 11:38:31 +00:00
Fix Python 3.10 compatibility: Replace datetime.UTC with timezone.utc
- Created datetime_compat module to provide UTC constant using timezone.utc - Updated all direct UTC imports to use compatibility module - Added tests to verify UTC timezone compatibility - Fixes #2171 Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
14
tests/utilities/test_datetime_compat.py
Normal file
14
tests/utilities/test_datetime_compat.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""Test datetime compatibility module."""
|
||||
from datetime import timezone
|
||||
|
||||
from crewai.utilities.datetime_compat import UTC
|
||||
|
||||
|
||||
def test_utc_timezone_compatibility():
|
||||
"""Test that UTC timezone is compatible with both Python 3.10 and 3.11+"""
|
||||
assert UTC == timezone.utc
|
||||
assert UTC.tzname(None) == "UTC"
|
||||
# Verify it works with datetime.now()
|
||||
from datetime import datetime
|
||||
dt = datetime.now(UTC)
|
||||
assert dt.tzinfo == timezone.utc
|
||||
Reference in New Issue
Block a user