Skip to content

Add note about exit code in example code for pytest.main() #8790

@ingomueller-net

Description

@ingomueller-net

I have just noticed that I have been calling pytest.main() for years in several projects and ignored the exit code. This is obviously really bad for unit tests; the only reason I have not noticed is that I have used the python -m pytest invocation method in CI -- until today.

The problem, in my opinion, is that the one example in the documentation ignores the exit code as well. It does mention that the function returns the exit code but giving an example where that code is used would be more explicit. For example:

if __name__ == '__main__':
    sys.exit(pytest.main(sys.argv))

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributorstatus: help wanteddevelopers would like help from experts on this topictype: docsdocumentation improvement, missing or needing clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions