Skip to content

Commit 94e3633

Browse files
committed
fix(test): Fix UTC import in test to support python 3.10
1 parent 6376a24 commit 94e3633

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

tests/asynchronous/document/test_instance.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
import pickle
44
import uuid
55
import weakref
6-
from datetime import datetime, UTC
6+
from datetime import datetime
7+
try:
8+
# Python 3.11+
9+
from datetime import UTC
10+
except ImportError:
11+
# Python ≤ 3.10
12+
from datetime import timezone
13+
UTC = timezone.utc
714
from unittest.mock import AsyncMock
815

916
import bson

tests/asynchronous/document/test_timeseries_collection.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import asyncio
22
import unittest
3-
from datetime import datetime, timedelta, UTC
3+
from datetime import datetime, timedelta
4+
5+
try:
6+
# Python 3.11+
7+
from datetime import UTC
8+
except ImportError:
9+
# Python ≤ 3.10
10+
from datetime import timezone
11+
UTC = timezone.utc
412

513
from mongoengine import (
614
DateTimeField,

tests/fixtures.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import pickle
2-
from datetime import datetime, UTC
2+
from datetime import datetime
3+
4+
try:
5+
# Python 3.11+
6+
from datetime import UTC
7+
except ImportError:
8+
# Python ≤ 3.10
9+
from datetime import timezone
10+
UTC = timezone.utc
311

412
from mongoengine import *
513
from mongoengine import signals

0 commit comments

Comments
 (0)