ionelmc / pytest-benchmark

py.test fixture for benchmarking code
BSD 2-Clause "Simplified" License
1.22k stars 115 forks source link

`datetime.utcnow()` deprecated in Python 3.12 #240

Closed The-Compiler closed 7 months ago

The-Compiler commented 1 year ago

datetime.utcnow() seems to be deprecated in Python 3.12, which with -Werror leads to:

  [...]
  File ".../python3.12/site-packages/pytest_benchmark/plugin.py", line 213, in pytest_addoption
    tag = get_tag()
          ^^^^^^^^^
  File ".../python3.12/site-packages/pytest_benchmark/utils.py", line 75, in get_tag
    parts = [info['id'], get_current_time()]
                         ^^^^^^^^^^^^^^^^^^
  File ".../python3.12/site-packages/pytest_benchmark/utils.py", line 201, in get_current_time
    return datetime.utcnow().strftime("%Y%m%d_%H%M%S")
           ^^^^^^^^^^^^^^^^^
DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.now(datetime.UTC).