GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-62432: Return unsuccessfully if no unit tests were run by mgorny · Pull Request #24893 · python/cpython

Conversation

@mgorny

@mgorny mgorny commented Mar 16, 2021 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Change unittest.TestResult.wasSuccessful() to return False if no tests
were found. Update the runner to explicitly print "No tests found"
to indicate the problem better. Add a test ensuring that
wasSuccessful() still returns True if all tests were skipped, including
the special case of SkipTest exception in setUpClass() method.

This aids greatly with automated testing where an unexpected breakage
of test discovery could not be caught cleanly, as the test runner
returned success if no tests were found. This is unlikely to be
the expected behavior in real usage.

https://bugs.python.org/issue18232

  • Issue: running a suite with no tests is not an error #62432

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mgorny
bpo-18232: Return unsuccessfully if no unit tests were run
1a3cecf
Change unittest.TestResult.wasSuccessful() to return False if no tests
were found.  Update the runner to explicitly print "No tests found"
to indicate the problem better.  Add a test ensuring that
wasSuccessful() still returns True if all tests were skipped, including
the special case of SkipTest exception in setUpClass() method.

This aids greatly with automated testing where an unexpected breakage
of test discovery could not be caught cleanly, as the test runner
returned success if no tests were found.  This is unlikely to be
the expected behavior in real usage.
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 16, 2021
@bedevere-bot bedevere-bot added the awaiting review label Mar 16, 2021
@github-actions

github-actions Bot commented Apr 16, 2021

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 16, 2021
iritkatriel
iritkatriel reviewed May 7, 2021
View reviewed changes
Comment thread Doc/library/unittest.rst
Returns ``False`` if there were any :attr:`unexpectedSuccesses`
from tests marked with the :func:`expectedFailure` decorator.

.. versionchanged:: 3.10b1

@iritkatriel iritkatriel May 7, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This will probably need to be 3.11 now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/unittest.rst
Return ``True`` if all tests run so far have passed, otherwise returns
``False``.
Return ``True`` if all tests run so far have passed and at least one test
was found, otherwise returns ``False``.

@iritkatriel iritkatriel May 7, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The code checks testsRun + testsSkipped > 0, so it's not exactly "was found" (what if many were found but we haven't started running anything yet?)

nit: I think it's easier to understand if the sentence lists the conditions chronologically, something like: "at least one test has been executed or skipped and no test has failed so far".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/unittest/runner.py
run = result.testsRun
self.stream.writeln("Ran %d test%s in %.3fs" %
(run, run != 1 and "s" or "", timeTaken))
if run > 0 or len(result.skipped) > 0:

@iritkatriel iritkatriel May 7, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd abstract the run > 0 or len(result.skipped) calculation as a method on TestResult, then you won't have it repeated twice. And you can give it a name indicating what it means.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rbtcollins rbtcollins mentioned this pull request Apr 10, 2022
running a suite with no tests is not an error #62432
Closed
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 5, 2022
@StanFromIreland

StanFromIreland commented Jul 28, 2025

Copy link
Copy Markdown
Member

This was completed in 76632b8

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StanFromIreland StanFromIreland closed this Jul 28, 2025
@StanFromIreland StanFromIreland changed the title bpo-18232: Return unsuccessfully if no unit tests were run gh-62432: Return unsuccessfully if no unit tests were run Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@mgorny @StanFromIreland @iritkatriel @the-knights-who-say-ni @ezio-melotti @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.