You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could it be a race condition? (pytest-xdist is in use)
Maybe pytest_runtest_makereport is executed in the worker process, not in the main process. And terminal reporter runs in the main process. And their output gets mixed without synchronization.
pytest_runtest_makereport is intended for generating per-test report data, and pytest_runtest_logreport is for processing (in this case - printing) the data.
It was part of #14, which cleaned up several things, based on pytest docs & examples. It might have been because there was an issue getting the correct line number or something like that (I don't remember exactly), but if you'd like to try using pytest_runtest_logreport, as long as it doesn't break the output, I'd be supportive.
@amezin Any updates on this. Apparently the current version of the plugin does not work. Yes, like most I am using xdist. I was not able to see any ::error text in raw output either.
I also raised #81 as this would be a first step that would need sorting before the others.
Looks like somewhere (probably in a 7.x release) the line numbers started getting messed up. PyTest 6.x reports line 11 in our test suite, but pytest 7.* reports line 1168.
Looks like somewhere (probably in a 7.x release) the line numbers started getting messed up. PyTest 6.x reports line 11 in our test suite, but pytest 7.* reports line 1168.
FYI, this bug only hits some errors (chained ones?). Only one in our test suite. It causes unrealistic numbers which cause the annotation to not show up. “Some annotations disappear due to incorrect line numbers” for PyTest 7.4+ might be a better way to describe it.
I think we just need a corrected line number calculation for the chained case on 7.4+. Won’t have much time till after PyCON though.
Activity
edgarrmondragon commentedon Jul 26, 2023
@amezin can you confirm if the annotations are actually printed by running
locally.
I see you're using tox and setting
passenv, so the problem may be the paths generated by the plugin do not match the repo structure.amezin commentedon Jul 27, 2023
But another failure of the same test (just with different parameters) generated an annotation.
Also, I've had issues with mismatching paths once - but annotations were still generated.
When I look at raw logs I see some escape sequences preceding
::error:Could it be a race condition? (pytest-xdist is in use)
Maybe
pytest_runtest_makereportis executed in the worker process, not in the main process. And terminal reporter runs in the main process. And their output gets mixed without synchronization.amezin commentedon Jul 27, 2023
TerminalReporter prints its output in
pytest_runtest_logreport: https://github.com/pytest-dev/pytest/blob/main/src/_pytest/terminal.py#L567Maybe it's a more appropriate hook?
xdist calls
pytest_runtest_logreportin the main process: https://github.com/pytest-dev/pytest-xdist/blob/6f0cb26fc090bbaec3a6d32ad4d3a3bb3464b84a/src/xdist/dsession.py#L283 (and also implements it in workers - to send reports to the main process).pytest_runtest_makereportis intended for generating per-test report data, andpytest_runtest_logreportis for processing (in this case - printing) the data.https://pytest-xdist.readthedocs.io/en/latest/how-it-works.html#how-it-works (see item 8)
amezin commentedon Jul 27, 2023
I see that the plugin was using
pytest_runtest_logreport, but then switched topytest_runtest_makereportin 9264fb4@henryiii what was the reason?
Use `pytest_runtest_logreport` hook again
henryiii commentedon Jul 27, 2023
It was part of #14, which cleaned up several things, based on pytest docs & examples. It might have been because there was an issue getting the correct line number or something like that (I don't remember exactly), but if you'd like to try using
pytest_runtest_logreport, as long as it doesn't break the output, I'd be supportive.Use `pytest_runtest_logreport` hook again
edgarrmondragon commentedon Jul 31, 2023
Hmm I can actually see annotations using version v0.2.0 of this package:

amezin commentedon Aug 1, 2023
@edgarrmondragon I don't understand you comment.
The issue is about
Sometimes. Sometimes there are annotations for all failures. Sometimes some annotations are missing.
Also it looks like you have to use xdist to reproduce the issue.
ssbarnea commentedon Mar 1, 2024
@amezin Any updates on this. Apparently the current version of the plugin does not work. Yes, like most I am using xdist. I was not able to see any
::errortext in raw output either.I also raised #81 as this would be a first step that would need sorting before the others.
PS. I can help with review/merges.
henryiii commentedon May 15, 2024
Looks like somewhere (probably in a 7.x release) the line numbers started getting messed up. PyTest 6.x reports line 11 in our test suite, but pytest 7.* reports line 1168.
edgarrmondragon commentedon May 15, 2024
@henryiii fwiw I narrowed it down to 7.4.0
henryiii commentedon May 15, 2024
Ah, thanks! I was trying but I think there's a bug in the new
uv run:I hadn't noticed it upgrade pytest. And then there are two!
henryiii commentedon May 15, 2024
I believe ExceptionRepr now has a subclass ExceptionChainRepr.
henryiii commentedon May 15, 2024
FYI, this bug only hits some errors (chained ones?). Only one in our test suite. It causes unrealistic numbers which cause the annotation to not show up. “Some annotations disappear due to incorrect line numbers” for PyTest 7.4+ might be a better way to describe it.
I think we just need a corrected line number calculation for the chained case on 7.4+. Won’t have much time till after PyCON though.
Use `pytest_runtest_logreport` hook again
henryiii commentedon Jan 17, 2025
I think this was fixed in #97.