Skip to content

Deprecation warnings are silenced while time is mocked #445

@tamird

Description

@tamird

Python Version

3.12.2

pytest Version

8.1.1

Package Version

2.14.1

Description

def test_utcnow_warning() -> None:
    with time_machine.travel(0):
        datetime.utcnow() # no warning
    datetime.utcnow() # DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions