Skip to content

Propagate timestamps from CallInfo to TestReport objects - #10711

Merged
nicoddemus merged 3 commits into
pytest-dev:mainfrom
HTRafal:timestamps
Feb 10, 2023
Merged

nicoddemus merged 3 commits into
pytest-dev:mainfrom
HTRafal:timestamps

Conversation

@HTRafal

@HTRafal HTRafal commented Feb 6, 2023

Copy link
Copy Markdown
Contributor

TestReport objects stored only the information about stage duration. This is not enough to correlate pytest stages with external events. Timestamps are already there in CallInfo. They just needed to be propagated to TestReport objects, so that they can be read when TestReports are exported externally (for example with --reportlog option)

Closes #10710

TestReport objects stored only the information about stage duration.
This is not enough to correlate pytest stages with external events.
Timestamps are already there in CallInfo. They just needed to be
propagated to TestReport objects, so that they can be read when
TestReports are exported externally (for example with --reportlog
option)

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just for the sake of it we should add some unittest for the feature

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As @RonnyPfannschmidt mentions, we need a unittest for the feature, ideally we also need to ensure that the serialization/unserialization will work for those new attributes if we want to make sure it will also work out of the box with pytest-reportlog.

Comment thread changelog/10710.improvement.rst Outdated
@HTRafal
HTRafal force-pushed the timestamps branch 3 times, most recently from 38dfbdd to 2808854 Compare February 9, 2023 12:47
@HTRafal
HTRafal requested a review from nicoddemus February 9, 2023 12:58

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, wondering if we have a way to make a unittest for this

@HTRafal

HTRafal commented Feb 10, 2023

Copy link
Copy Markdown
Contributor Author

@RonnyPfannschmidt what do you mean? I added a unit test in testing/test_reports.py that tests serialization of the new fields. That should be enough for pytest-reportlog to work as it only calls pytest_report_to_serializable and saves the result to a json file.

@RonnyPfannschmidt

Copy link
Copy Markdown
Member

The test is indeed enough, it however involves quite some machinery that we currently have no nicely testable way to leave out

@RonnyPfannschmidt

Copy link
Copy Markdown
Member

Aka there should be one test that just verifies the transfer from callinfo to report and a second test that only verifies the serialization

But we lack the infrastructure for those pinpointed tests, so we can't exactly ask for their addition in good conscience

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, looks great!

@nicoddemus
nicoddemus merged commit 5e1c3d2 into pytest-dev:main Feb 10, 2023
imgbot Bot pushed a commit to kkipngenokoech/pytest that referenced this pull request Apr 18, 2026
…10711)

This makes it possible to correlate pytest stages with external events, and also makes it readable when TestReports are exported externall (for example with pytest-reportlog).

Closes pytest-dev#10710
imgbot Bot pushed a commit to kkipngenokoech/pytest that referenced this pull request Apr 18, 2026
…10711)

This makes it possible to correlate pytest stages with external events, and also makes it readable when TestReports are exported externall (for example with pytest-reportlog).

Closes pytest-dev#10710
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.

Include timestamps in reportlog

3 participants