Repository navigation
Replies: 1 comment
|
Hi @Northxw Both forms are valid. The return value of (category, shortletter, verbose)and the third value can currently be either: "PASSED"or: ("PASSED", {"green": True})The difference is styling. A plain string lets pytest apply its normal/default styling: @pytest.hookimpl
def pytest_report_teststatus(report, config):
if report.when == "call" and report.passed:
return "passed", "T", "😀"If you want to explicitly control terminal markup, return: @pytest.hookimpl
def pytest_report_teststatus(report, config):
if report.when == "call" and report.passed:
return "passed", "T", ("😀", {"green": True})
if report.when == "call" and report.failed:
return "failed", "E", ("😔", {"red": True, "bold": True})So this: ("😀", {"yellow": True})means:
while: "😀"is simply the verbose text without an explicit markup override. Current pytest defines the hook type as essentially: tuple[
str,
str,
str | tuple[str, Mapping[str, bool]]
]The supported terminal markup includes options such as: So your two examples are both correct; use the tuple form only when you need explicit styling. Please mark this answer as accepted if it helped, thank you. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I implemented the pytest_report_teststatus hook method in the conftest.py file, but when I formulated the return value in combination with the official pytest documentation, I had a doubt.
So, my doubt is where can I know the format of the detailed words, for example, I can write it like this
report.outcome, 'T', ("😀", {"yellow": True}), or I can write it like thisreport.outcome, 'T', "😀".Or, where can I learn about the resulting format of verbose word,Such as
("😀", {"yellow": True})and "😀".This is a small and detailed question, but I'm looking forward to an answer, thanks a lot!
All reactions