Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix py312 warning for datetime.utcnow #1661

Merged
merged 3 commits into from
Jun 18, 2024

Conversation

waketzheng
Copy link
Contributor

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:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@coveralls
Copy link

coveralls commented Jun 18, 2024

Pull Request Test Coverage Report for Build 9564975579

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.049%

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

💛 - Coveralls

@abondar abondar merged commit 222aaf5 into tortoise:develop Jun 18, 2024
7 checks passed
@waketzheng waketzheng deleted the fix-utcnow-warning branch June 24, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants