Open TobiasKadelka opened 8 months ago
This issue is actually two:
The word 'filter' in that message is colored, which we don't want. This is because apparently rich
enables syntax highlighting by default. PR #543 fixes this.
This failure doesn't happen to me and according to OP also not always, suggesting that something differs WRT whether capsys
is written to by rich
as if it was a terminal or not. This needs further investigation.
I'm going to share some notes here. I have made no progress on this, but have eliminated a few things:
I can confirm that running the test directly does not reproduce the problem:
pytest -vv onyo/lib/tests/test_commands_get.py
And when I try to manually reproduce the exact order the tests ran in when they failed, it doesn't fail:
pytest -vv -p no:randomly onyo/commands/tests/test_init.py onyo/commands/tests/test_unset.py onyo/commands/tests/test_shell-completion.py onyo/commands/tests/test_mkdir.py onyo/commands/tests/test_cat.py onyo/lib/tests/test_commands_set.py onyo/lib/tests/test_Filter.py onyo/tests/test_main.py onyo/lib/tests/test_commands_mv.py onyo/lib/tests/test_commands_get.py
I tried dozens of combinations when running the tests directly. I was never able to reproduce the error.
I am only able to reproduce it when I run all tests. I can confirm that it affects me even with randomly
disabled:
pytest -vv -p no:randomly
Neither running reset
on my terminal nor loading a new terminal helps.
I run foot
, reporting as xterm-256color
. I tried running under xterm
(reporting as xterm
) and it still failed there.
So... I don't think there's something particular to my terminal environment influencing this. Especially since Tobias sees this problem on macOS as well.
So I think it's a Python issue. But from where, is still unclear.
Since there is currently a lot of discussion going on in regards to printing and colors (#706, #702), I read through this issue again. It is not fully related, but I am still wondering if the original issue still exists?
The issue still exists. We have both ui.print()
and ui.rich_print()
.
@aqw found an error that appeared in one of the tests for
onyo_get()
:I can reproduce this error exclusively when I run all tests -- if I just run the one for the file with the error (
REPO_ROOT=$PWD pytest onyo/lib/tests/test_commands_get.py -vv
) the test is not raised.In the test, we assert for a specific string, but
ui.rich_print()
adds some special characters to the output, hence the error.541 changes the rich-print to a normal print, which removes the occurence of the error.
ui.print()
and removeui.rich_print()
on the long run, i.e. unify both functions into one that decides when to rich-print and when not.55 wants to colorize certain output; this issue should be considered when unifying both functions.