Closed pgoiporia closed 1 month ago
It looks like pytest-xdist
just doesn't support the -s
flag -- see discussion in https://github.com/pytest-dev/pytest-xdist/issues/354.
But there might be workarounds...
Yeah it looks like the print statement needs to send the message to stderr for it to show.
You can add something like print("Message here", file=sys.__stderr__)
or you can run the test manually with pytest (without running ./checks/pytest_.py
) to avoid the multi threaded tests.
We can also add an flag to run without xdist if needed, but I think the above solutions are easier.
You can add something like
print("Message here", file=sys.__stderr__)
I was using print("Message here", file=sys.stderr)
initially which didn't seem to work, but can confirm print("Message here", file=sys.__stderr__)
does work. Though as you mention, I usually just use pytest ...
for specific debugging.
We can also add an flag to run without xdist if needed, but I think the above solutions are easier.
Requested in https://github.com/Infleqtion/client-superstaq/issues/990
linking @PalashGoiporia's proposal (which makes sense to me): https://github.com/Infleqtion/client-superstaq/issues/990#issuecomment-2231300487
(imo we should also treat the --incremental
flag like passing in specific tests)
What is happening?
Typically, for debugging tests, I will place print statements in my code and see what they return in the CLI. However, pytest doesn't seem to be returning these print statements anymore.
How can we reproduce the issue?
Add a print statement to any test.
What should happen?
It should return the print statement, but won't.
Environment
N/A
Any additional context?
N/A