mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
housekeep: replace deprecated datetime functions
tests show warnings for deprecated utc functions with python 3.12 Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
parent
ffddf63975
commit
afb7af3e27
9 changed files with 21 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
|||
import warnings
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import exc as sa_exc
|
||||
|
@ -17,7 +17,7 @@ def setup(db_test):
|
|||
|
||||
@pytest.fixture
|
||||
def ban() -> Ban:
|
||||
ts = datetime.utcnow() + timedelta(seconds=30)
|
||||
ts = datetime.now(UTC) + timedelta(seconds=30)
|
||||
with db.begin():
|
||||
ban = create(Ban, IPAddress="127.0.0.1", BanTS=ts)
|
||||
yield ban
|
||||
|
@ -30,7 +30,7 @@ def test_ban(ban: Ban):
|
|||
|
||||
def test_invalid_ban():
|
||||
with pytest.raises(sa_exc.IntegrityError):
|
||||
bad_ban = Ban(BanTS=datetime.utcnow())
|
||||
bad_ban = Ban(BanTS=datetime.now(UTC))
|
||||
|
||||
# We're adding a ban with no primary key; this causes an
|
||||
# SQLAlchemy warnings when committing to the DB.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue