From 1ddb3caa4a8bc7487d070d39c24d5e5e609e0688 Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Thu, 10 Apr 2025 11:35:18 +1000 Subject: [PATCH] Replace use of utcnow() with now() for Python 3.13 compatibility --- alembic/script/base.py | 3 +-- tests/test_script_production.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/alembic/script/base.py b/alembic/script/base.py index 30df6ddb..e4de9c51 100644 --- a/alembic/script/base.py +++ b/alembic/script/base.py @@ -629,8 +629,7 @@ class ScriptDirectory: "Can't locate timezone: %s" % self.timezone ) from None create_date = ( - datetime.datetime.utcnow() - .replace(tzinfo=datetime.timezone.utc) + datetime.datetime.now(tz=datetime.timezone.utc) .astimezone(tzinfo) ) else: diff --git a/tests/test_script_production.py b/tests/test_script_production.py index 7857f5d4..18be6d39 100644 --- a/tests/test_script_production.py +++ b/tests/test_script_production.py @@ -235,7 +235,7 @@ class ScriptNamingTest(TestBase): with mock.patch( "alembic.script.base.datetime", mock.Mock( - datetime=mock.Mock(utcnow=lambda: given, now=lambda: given), + datetime=mock.Mock(now=lambda tz=None: given), timezone=datetime.timezone, ), ): -- 2.47.3