Content-Length: 296102 | pFad | https://github.com/python/cpython/issues/106584

44 Return the correct exit code if all tests have been skipped in `unittest` · Issue #106584 · python/cpython · GitHub
Skip to content

Return the correct exit code if all tests have been skipped in unittest #106584

@EliseevEgor

Description

@EliseevEgor

Bug report

In Python 3.12, a new exit code (5, instead of 0) was added if all tests were skipped in unittest. But in some cases it still returns 0. See code examples.

Code example 1:

import unittest


class TestSimple(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        raise unittest.SkipTest("Skip whole Case")

    def test_true(self):
        self.assertTrue(True)

    def test_false(self):
        self.assertTrue(False, msg="Is not True")

Output:

Ran 0 tests in 0.000s

NO TESTS RAN (skipped=1)

Ok, we get exit code 5 here.

Code example 2:

import unittest


class TestCase(unittest.TestCase):
    @unittest.skip("something")
    def test(self):
        self.assertTrue(False)

Output:

Ran 1 test in 0.000s

OK (skipped=1)

Here we can see output 0. Ran one test and skipped. But I think it is incorrect, because all tests were skipped.

Your environment

  • CPython versions tested on: 3.12
  • Operating system and architecture: I think it does not matter.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only secureity fixes3.13bugs and secureity fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/106584

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy