Skip to content

Commit

Permalink
use offset-aware datetime API
Browse files Browse the repository at this point in the history
it is distracting at seeing the warning like when running test:

```
  /home/kefu/.local/lib/python3.12/site-packages/pytest_elk_reporter.py:281: 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).
    timestamp=datetime.datetime.utcnow().isoformat(),
```

so, in this change, let's switch to the offset-aware datetime API
to silence this warning.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov authored and fruch committed Jul 31, 2024
1 parent 15ec2ec commit 2cc926a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pytest_elk_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def report_test(self, item_report, outcome, old_report=None):
self.stats[outcome] += 1
test_data = dict(
item_report.user_properties,
timestamp=datetime.datetime.utcnow().isoformat(),
timestamp=datetime.datetime.now(tz=datetime.timezone.utc).isoformat(),
name=item_report.nodeid,
outcome=outcome,
duration=item_report.duration,
Expand Down

0 comments on commit 2cc926a

Please sign in to comment.