tortoise / tortoise-orm

Familiar asyncio ORM for python, built with relations in mind
https://tortoise.github.io
Apache License 2.0
4.37k stars 355 forks source link

fix py312 warning for `datetime.utcnow` #1661

Closed waketzheng closed 1 week ago

waketzheng commented 1 week ago

Description

Actions log of Run ci with Python3.12 print the following warning:

tests/fields/test_time.py::TestDatetimeFields::test_get_utcnow
  /home/runner/work/tortoise-orm/tortoise-orm/tests/fields/test_time.py:78: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    now = datetime.utcnow().replace(tzinfo=get_default_timezone())

Motivation and Context

While fixing the warning above, I found that test_time.py can be refactor to reduce duplicated code.

How Has This Been Tested?

make ci

Checklist:

coveralls commented 1 week ago

Pull Request Test Coverage Report for Build 9564975579

Details


Totals Coverage Status
Change from base Build 9563237685: 0.0%
Covered Lines: 5868
Relevant Lines: 6492

💛 - Coveralls