From: Jens Troeger Date: Thu, 10 Apr 2025 01:35:18 +0000 (+1000) Subject: Replace use of utcnow() with now() for Python 3.13 compatibility X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1ddb3caa4a8bc7487d070d39c24d5e5e609e0688;p=thirdparty%2Fsqlalchemy%2Falembic.git Replace use of utcnow() with now() for Python 3.13 compatibility --- 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, ), ):