New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: avoid rounding microsecond to 1_000_000
#11861
Merged
nicoddemus
merged 3 commits into
pytest-dev:main
from
dqkqd:fix-bug-formatter-round-microsecond-to-1000000
Jan 27, 2024
Merged
fix: avoid rounding microsecond to 1_000_000
#11861
nicoddemus
merged 3 commits into
pytest-dev:main
from
dqkqd:fix-bug-formatter-round-microsecond-to-1000000
Jan 27, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nicoddemus
requested changes
Jan 27, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than my comment, could you please also add a changelog entry? Thanks!
dqkqd
force-pushed
the
fix-bug-formatter-round-microsecond-to-1000000
branch
from
January 27, 2024 11:56
c489824
to
6d69288
Compare
Thanks for reviewing, I added comment and changelog. |
nicoddemus
approved these changes
Jan 27, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, appreciate it!
nicoddemus
added
the
needs backport
applied to PRs, indicates that it should be ported to the current bug-fix branch
label
Jan 27, 2024
nicoddemus
added
backport 8.0.x
and removed
needs backport
applied to PRs, indicates that it should be ported to the current bug-fix branch
labels
Jan 27, 2024
jsuchenia
pushed a commit
to jsuchenia/adventofcode
that referenced
this pull request
Jan 29, 2024
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pytest](https://docs.pytest.org/en/latest/) ([source](https://github.com/pytest-dev/pytest), [changelog](https://docs.pytest.org/en/stable/changelog.html)) | dev | major | `7.4.4` -> `8.0.0` | --- ### Release Notes <details> <summary>pytest-dev/pytest (pytest)</summary> ### [`v8.0.0`](https://github.com/pytest-dev/pytest/releases/tag/8.0.0): pytest 8.0.0 (2024-01-27) [Compare Source](pytest-dev/pytest@7.4.4...8.0.0) See [8.0.0rc1](https://github.com/pytest-dev/pytest/releases/tag/8.0.0rc1) and [8.0.0rc2](https://github.com/pytest-dev/pytest/releases/tag/8.0.0rc2) for the full changes since pytest 7.4! #### Bug Fixes - [#​11842](pytest-dev/pytest#11842): Properly escape the `reason` of a `skip <pytest.mark.skip ref>`{.interpreted-text role="ref"} mark when writing JUnit XML files. - [#​11861](pytest-dev/pytest#11861): Avoid microsecond exceeds `1_000_000` when using `log-date-format` with `%f` specifier, which might cause the test suite to crash. </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMzAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEzMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=--> Reviewed-on: https://git.apud.pl/jacek/adventofcode/pulls/52 Co-authored-by: Renovate <renovate@apud.pl> Co-committed-by: Renovate <renovate@apud.pl>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm using pytest with python 3.9, and my
log-date-format
is enabled for microseconds. However, my testsuite occasionally fails with the message below:I'm pretty sure the issue occurred because we're rounding up microsecond here, which make it exceeds 999999.
pytest/src/_pytest/logging.py
Lines 72 to 75 in ac2cd72
As we can see
msecs
can take more than 4 digits after decimal points, hence it can be rounded up to1_000_000
after multiplying with1_000
. (in python 3.9)This is "fixed" in python 3.10 and 3.11 python/cpython#89047
They floored
msecs
so it will always never be rounded to1_000_000
.However, since we also support 3.8 and 3.9, I think we should fix this by flooring microsecond as well.
(I don't know how to write test for this case without mocking
time.time()
)