-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Custom markers don't show custom color in 'short test summary info' section #9961
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
Comments
I hacked together a solution to this problem by slightly modifying In plugin.py or conftest.py:
In terminal.py:
This results in the |
Yeah that color coding of the status is hard coded in One solution would be to extend Possibly a better solution is to return |
Hey, thanks for the reply. Is this something we should leave to the devs, or would it be something I could try myself and submit a PR for? I haven't contributed to a public repo yet so I don't know how these things work. :-) |
I'm OK with implementing the change I outlined above (the |
seems fine to me! it could even be made backward compatible (with deprecation) by making |
as far as im understanding, the desire here is to either take the color of the verbose word, or the symbol and apply it to the status line i would like to propose that we jsut take the first color given to category as well, and warn if mutliple values are given |
i want to weight in, that we ideally avoid propagating the terminal-writer styling apis any more than they are already in by accident, |
is the eventual proposal to replace coloring with rich? as much as rich seems really cool I think it's a little unstable at the moment and a fairly heft dependency to pull in |
im not proposing to replace coloring with rich anytime soon (in fact - if ever i would like to see a official pytest-rich/pytest-textual plugin in future that enables more fancy output without imposing the details on normal testruns but i want to avoid adding places of the terminalwriter styling api which is quite dated and locks us into 16 color terminals + no theming forever |
Same thoughts here: really cool but a hefty dependency to bring in to a popular test runner.
I had exactly the same nagging thought, but I think in this case we can be conservative and only allow the normal color names that we support, as strings: This seems safe enough because it is generic and can be easily ported to something else in the future.
I have created https://github.com/nicoddemus/pytest-rich with exactly that purpose in mind. 😁 |
@nicoddemus what i want to propose is that we take the color, that we support for the verbose name/name anyway - and also use it for the unknown statuses currently: any unknown status -> yellow desired -> unknown status but with verbose color -> green + color that extra status using its given color for that we would have to pass markup into the status counting, and perhaps warn if a different value is passed + choose if we want the first or the last |
Oh I'm sorry, I misunderstood the issue: @hookspec(firstresult=True)
def pytest_report_teststatus(
report: Union["CollectReport", "TestReport"], config: "Config"
) -> Tuple[str, str, Union[str, Mapping[str, bool]]]:
... We are talking obviously about the counts: Can you clarify what you mean here?
The |
@nicoddemus bascially i want to pass the markup that was added in that hook into the status collection as well, that way we can use the color markup we already use in multiple places (the character and the word) in the summary as well |
This has actually been fixed by #9875 and will be available in pytest 7.2. |
Until this gets implemented, for non-production code it's possible to import the internal python module and add to the internal import _pytest.terminal
_pytest.terminal._color_for_type['incompatible'] = 'red' |
Discussed in #9958
Originally posted by jeffwright13 May 14, 2022
At the end of a pytest run, you have a section called "short test summary info," which terminates in a single line that shows final metrics, all color-coded according to outcome. It doesn't appear as if this final line uses the custom color to color-code tests that are marked with custom markers. I do see that the initial "test session starts" section does color-code those tests, however.
Am I missing something or is this a deficiency in the final section processing code? I'd like to see that final line show my 'snowflake' tests in cyan!
Output:

pytest.ini:
plugin.py:
test1.py:
test2.py:
test_snowflake.py:
The text was updated successfully, but these errors were encountered: