-
Notifications
You must be signed in to change notification settings - Fork 76
datetime.datetime.utcnow() is deprecated, replace with a central utility
#658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| del runner | ||
| self.assertTrue(output.get("stop")) | ||
| self.assertLess(output["stop"], endtime) | ||
| self.assertLess(output["stop"], endtime.replace(tzinfo=None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a tz-aware comparison, removes the tz from the endtime
| self.assertFalse(runner.is_alive()) | ||
| self.assertTrue(output.get("stop")) | ||
| self.assertLess(output["stop"], endtime) | ||
| self.assertLess(output["stop"], endtime.replace(tzinfo=None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a tzaware comparison, removes tzinfo for comparison
csp/utils/datetime.py
Outdated
|
|
||
|
|
||
| def utc_now() -> datetime: | ||
| return datetime.now(timezone.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add replace(tzinfo=None) here so its consistent with current utcnow() calls and potential csp expectations
Signed-off-by: Will Rieger <will.r.rieger@gmail.com>
datetime.datetime.utcnow()is deprecated and creates lots of warnings in tests, addedutc_now()tocsp.utils.datetime