flask-sqlalchemy icon indicating copy to clipboard operation
flask-sqlalchemy copied to clipboard

Stop using datetime.utcnow() in tests

Open s-t-e-v-e-n-k opened this issue 1 year ago • 2 comments

datetime.utcnow() is deprecated for Python 3.12+, and raises a warning. Since warnings are treated as errors, this results in test failures. Since utcnow calls are done by the SQLAlchemy mapping machinery, we need to use a callable.

Fixes #1303

Checklist:

  • [x] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • [x] Add or update relevant docs, in the docs folder and in code.
  • [x] Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • [x] Add .. versionchanged:: entries in any relevant code docs.
  • [x] Run pre-commit hooks and fix any issues.
  • [x] Run pytest and tox, no tests failed.

s-t-e-v-e-n-k avatar Jan 31 '24 05:01 s-t-e-v-e-n-k

I have addressed both comments, thanks!

s-t-e-v-e-n-k avatar Feb 02 '24 03:02 s-t-e-v-e-n-k

@davidism Thanks, I've reverted that bit.

s-t-e-v-e-n-k avatar Feb 05 '24 09:02 s-t-e-v-e-n-k

Sorry, completely forgot about this PR and ended up fixing it myself when doing some updates. Thanks for working on it!

davidism avatar Apr 25 '24 19:04 davidism