-
Notifications
You must be signed in to change notification settings - Fork 40
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
fix utcnow() deprecation warning #69
Conversation
tests/plugins/test_mocked_time.py
Outdated
@@ -21,7 +21,9 @@ def test_disabled_mocked_time_raises_on_usage_attempt(mocked_time): | |||
assert not mocked_time.is_enabled | |||
|
|||
with pytest.raises(mocked_time_module.DisabledUsageError): | |||
mocked_time.set(datetime.datetime.utcnow()) | |||
mocked_time.set( | |||
datetime.datetime.now(datetime.timezone.utc).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.
как будто мы тут должны поддержать tz-aware даты, просто внутри переводить в utc и выкидывать часть с таймзоной
testsuite/mockserver/server.py
Outdated
@@ -281,7 +281,9 @@ def _log_request(self, started, request, response=None, exc=None): | |||
return | |||
fields = { | |||
'_type': 'mockserver_request', | |||
'timestamp': datetime.datetime.utcnow(), | |||
'timestamp': datetime.datetime.now(datetime.timezone.utc).replace( |
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.
возможно для этого лучше завести функцию где-то в utils
docs/other_plugins.rst
Outdated
@@ -54,7 +54,7 @@ used in a particular test: ``@pytest.mark.now('2016-12-01T12:00:00')`` or | |||
``@pytest.mark.now(enabled=True)``. | |||
|
|||
If time is not specified in ``@pytest.mark.now``, then | |||
``datetime.datetime.utcnow()`` value at the start of test is used as time value | |||
``datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)`` value at the start of test is used as time value |
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.
лучше написать, что будет использовано текущее время в utc
replace datetime.utcnow() withdatetime.now(datetime.timezone.utc).replace(tzinfo=None)