gh-117294: Report DocTestCase as skipped if all examples in the doctest are skipped (GH-117297)

This commit is contained in:
Malcolm Smith 2024-03-28 19:59:12 +00:00 committed by GitHub
parent efcc96844e
commit 29829b58a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 87 additions and 7 deletions

View file

@ -2281,12 +2281,13 @@ class DocTestCase(unittest.TestCase):
try:
runner.DIVIDER = "-"*70
failures, tries = runner.run(
test, out=new.write, clear_globs=False)
results = runner.run(test, out=new.write, clear_globs=False)
if results.skipped == results.attempted:
raise unittest.SkipTest("all examples were skipped")
finally:
sys.stdout = old
if failures:
if results.failed:
raise self.failureException(self.format_failure(new.getvalue()))
def format_failure(self, err):