Skip to content

[WIP] Set exit code to 5 when no tests are collected#199

Draft
Copilot wants to merge 3 commits intodevfrom
copilot/set-exit-code-to-five
Draft

[WIP] Set exit code to 5 when no tests are collected#199
Copilot wants to merge 3 commits intodevfrom
copilot/set-exit-code-to-five

Conversation

Copy link

Copilot AI commented Oct 15, 2025

  • Explore repository structure and understand the codebase
  • Verify current exit code behavior with manual tests
  • Confirm that exit code 5 is already returned when no tests are collected
  • Add test to verify exit code 5 when no changed files with --picked
  • Add test to verify exit code 0 when no changed files with --picked=first
  • Add test to verify exit code when tests fail with --picked
  • Run all tests to ensure no regressions
  • Update documentation in README
  • Verify the behavior with manual testing

Summary

The plugin already returns exit code 5 (NO_TESTS_COLLECTED) when no tests are collected with --picked. This PR adds:

  1. Three new tests to ensure this behavior is maintained:

    • Test for exit code 5 when no changed files with --picked
    • Test for exit code 0 when no changed files with --picked=first (all tests run)
    • Test for exit code 1 when tests fail with --picked
  2. Documentation in README explaining the exit code behavior to help users understand how the plugin respects pytest's standard exit codes

Original prompt

This section details on the original issue you should resolve

<issue_title>exit code</issue_title>
<issue_description>Hello, thank you for making this library.
How can I set the exit code to 5 instead of 1 when no tests are collected exit-codes.
Thanks

image

Comments on the Issue (you are @copilot in this section)

@anapaulagomes Feel free to open a PR for it :) @anapaulagomes Yes, please. ❤️ @TanyaKansal

Fixes #145


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@github-actions
Copy link

@Copilot your pull request is missing a changelog!

Copilot AI and others added 2 commits October 15, 2025 09:47
Co-authored-by: anapaulagomes <1899950+anapaulagomes@users.noreply.github.com>
Co-authored-by: anapaulagomes <1899950+anapaulagomes@users.noreply.github.com>
Copy link
Owner

@anapaulagomes anapaulagomes left a comment

Choose a reason for hiding this comment

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

Please add a line to the CHANGELOG file!



def test_exit_code_1_when_tests_fail_with_picked(testdir):
"""Verify exit code 1 (TESTS_FAILED) when changed tests fail"""
Copy link
Owner

Choose a reason for hiding this comment

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

The names of the tests are clear enough, so there's no need for docstrings in them.

Copy link
Owner

@anapaulagomes anapaulagomes left a comment

Choose a reason for hiding this comment

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

Need to actually implement the changes 😋

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.

exit code

2 participants