Skip to content

test,fix: Force pytest to exit zero when no tests are collected#221

Merged
kdestin merged 2 commits intoAzure-Samples:mainfrom
kdestin:fix-pytest-with-no-tests
Apr 7, 2025
Merged

test,fix: Force pytest to exit zero when no tests are collected#221
kdestin merged 2 commits intoAzure-Samples:mainfrom
kdestin:fix-pytest-with-no-tests

Conversation

@kdestin
Copy link
Copy Markdown
Member

@kdestin kdestin commented Apr 3, 2025

Description

Pytest considers it an error when pytest is invoked and no tests are collected (pytest-dev/pytest#2393). In the context of our local plugin that filters tests based on the git diff, this behavior is undesirable since it causes CI to fail when a PR doesn't touch a sample.

This PR updates our local plugin to force pytest to exit 0 when no tests are collected and any of the plugin's commandline arguments were provided.

Checklist

  • I have read the contribution guidelines
  • I have coordinated with the docs team (mldocs@microsoft.com) if this PR deletes files or changes any file names or file extensions.
  • This notebook or file is added to the CODEOWNERS file, pointing to the author or the author's team.

kdestin added 2 commits April 3, 2025 16:38
…amples

    pytest considers a failure to collect any tests as an error to be
    investigated. In the context of "only running pytest tests for
    changed samples", we'd expect this to happen somewhat commonly.

    This PR makes pytest exit OK when no tests were collected if this
    plugin is active.
@kdestin kdestin requested a review from a team as a code owner April 3, 2025 21:45
@kdestin kdestin enabled auto-merge (squash) April 7, 2025 20:22
@kdestin kdestin disabled auto-merge April 7, 2025 20:22
@kdestin kdestin merged commit 6eee1c4 into Azure-Samples:main Apr 7, 2025
3 checks passed
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.

1 participant