Skip to content
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

Catch unhandled exceptions from pytest. #266

Merged
merged 2 commits into from
Sep 28, 2020
Merged

Catch unhandled exceptions from pytest. #266

merged 2 commits into from
Sep 28, 2020

Conversation

smarlowucf
Copy link
Collaborator

- And retry the given test.
- Also, disable all pytest stdout capturing with -s option. This
seems to clash with img-proof which already redirects stdout to a
log file. https://docs.pytest.org/en/stable/capture.html
img_proof/ipa_cloud.py Show resolved Hide resolved
try:
result = pytest.main(cmds, plugins=[plugin])
except Exception:
result = 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pytest returns 1 if tests fail, 0 if sucess and any of 2, 3, 4 if there's some sort of handled exception. So 2 is arbitrary, it could be 2, 3 or 4. Below this section where the results are handled if the result is in (2, 3, 4) img-proof only adds a generic error instead of trying to parse the plugin report which won't exist in exception cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding that to the README and/or documentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add comments before merge.

@smarlowucf
Copy link
Collaborator Author

smarlowucf commented Sep 28, 2020

Add a comment to point to pytest error code link and use error code 3 which match exception cases.

@smarlowucf smarlowucf merged commit 86beafe into master Sep 28, 2020
@smarlowucf smarlowucf deleted the stdout-buffer branch September 28, 2020 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants