pytest: Timestamp in Pytest JUnit XML test report doesn't have time zone infomation

  • a detailed description of the bug or suggestion Last year, pytest add <timestamp> attribute to the JUnit test report. In the test report I can see the timestamp like timestamp="2020-08-17T10:14:39.548365"

It looks like pytest just takes the system time from OS, and save it to test report.
Unfortunately, this timestamp doesn’t have any timezone infomation, Our CI system will treat this timestamp as a UTC time, even the timestamp is actually from another time zone.

  • pytest and operating system versions pytest 5.2.1, I have seen the issue in both Linux and Windows

Is it possible to add timezone information to the timestamp attribute, or always use UTC time in timestamp?

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

I think it would be appropriate to always use UTC, and to include the timezone (i.e. utc) in the xml file.

https://blog.ganssle.io/articles/2019/11/utcnow.html has some good advice on the topic.