Skip to content
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

Merged
merged 5 commits into from
Feb 14, 2024
Merged

Conversation

sazikov-a
Copy link
Collaborator

replace datetime.utcnow() withdatetime.now(datetime.timezone.utc).replace(tzinfo=None)

@sazikov-a sazikov-a marked this pull request as ready for review February 14, 2024 07:26
@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как будто мы тут должны поддержать tz-aware даты, просто внутри переводить в utc и выкидывать часть с таймзоной

@@ -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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

возможно для этого лучше завести функцию где-то в utils

@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше написать, что будет использовано текущее время в utc

@vitek vitek merged commit 82a197d into yandex:develop Feb 14, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants