Open sblondon opened 3 weeks ago
For info, the tests with python3.11 are still green with the dirty patch.
Trying to write aware datetime by converting the datetime inside the SQL request fails. For example, in blog.index()
function:
posts = db.execute(
"SELECT p.id, title, body, datetime(p.created, 'localtime'), author_id, username"
" FROM post p JOIN user u ON p.author_id = u.id"
" ORDER BY datetime(p.created, 'localtime') DESC"
).fetchall()
it fails because the key created
in post
items is replaced by the key datetime(p.created, 'localtime')
.
I think the right way is to use a convert function like in the first post (and in the documentation). However, it would be better to reuse the local time instead of forcing to UTC.
I see you've been working on this issue, and I’d like to contribute if there's any part I can help with. Have you made any progress, or is there a specific task I can assist with?
The tests runned with
pytest
works with python3.11 and not in 3.12:How to reproduce:
In both cases, the webservice runs properly with
./venv3.1x/bin/flask --app flaskr run --debug
.However, running the tests show different results. In
venv3.11
, the 24 tests are green. Invenv3.12
virtualenv, there is 6 failures (and 18 green). The failures are due to aDeprecationWarning
which becomes an error:The full output is provided at the end of the bug report.
The
DeprecationWarning
is documented in the 3.12 release: 'default adapters and converters are now deprecated. Instead, use the Adapter and converter recipes and tailor them to your needs.' Copy-pasting blindly the recipes intests/conftest.py
,flaskr/__init__.py
andflaskr/db.py
does not fix the errors.The errors can be fixed by adding thoses lines in conftest.py:
It's probably not the best fix but it's a start.
Pytest output: