Is it possible to selectively skip pytest_report_teststatus()? #12601
Unanswered
ZChristiansen
asked this question in
Q&A
Replies: 1 comment 11 replies
-
the ask is not clear, the hook itself is part of the common flow, it seems like you want a plugin object you only add to pytest when opted in |
Beta Was this translation helpful? Give feedback.
11 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.
-
This method runs after every test to create a report. I am grabbing information from that report to then send to a few other methods that call APIs to save the test results to a server. This part is working fine; however, I don't always want to send the execution details to the server.
When I run the tests locally, perhaps troubleshooting or creating new tests, I don't want the results to be sent to the server. If the tests are running in the CICD pipeline, I do want them to be sent.
Is it possible to pass a command line argument that can be used to determine whether or not to continue reporting?
Working code
pytest_report_teststatus(report):
if report.when == "call"
get_data_from_report()
call_api1_to_log_to_server(with_data)
What I want
pytest_report_teststatus(report):
if donot_report is False: # how could I pass this as a command line argument, or as any argument to this method?
if report.when == "call"
get_data_from_report()
call_api1_to_log_to_server(with_data)
run the test
pytest --no-report
where --no-report ends up setting donot_report = true. I know how to add the command line option using pytest_addoption() and a fixture, I can't figure out how to get that value to pass to pytest_report_teststatus()
Beta Was this translation helpful? Give feedback.
All reactions