I'm running hundreds of tests on real phones using pytest and appium. Once in a time I'm getting few appium specific errors which are marking tests as failed but nothing was really checked. This errors are like below:
selenium.common.exceptions.WebDriverException: Message: Could not proxy command to remote server. Original error: Error: socket hang up
selenium.common.exceptions.WebDriverException: Message: Could not proxy command to remote server. Original error: Error: read ECONNRESET
selenium.common.exceptions.WebDriverException: Message: Could not proxy command to remote server. Original error: Error: read ECONNREFUSED
I don't want to mark test as failed in case of one of this errors but to skip this specific test.
Is there any possibility in pytest (hook or fixture) in case of failed testcase to check what was the reason of the fail and if there is one of the error messages from list above to change status of the test from FAIL to SKIP?
Edit after commend from @hoefling: I thought about xfail, but then I will have to add this marker to all of the existing tests and to remember about this in the new ones. Also using xfail I'll catch every occurrence of given exception but I want to catch only the ones which have that specific exception message. And mit's the reason why I was thinking about some hook to execute after test.