aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/unittest/main.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committershadchin <shadchin@yandex-team.com>2024-02-12 08:07:36 +0300
commitce1b7ca3171f9158180640c6a02a74b4afffedea (patch)
treee47c1e8391b1b0128262c1e9b1e6ed4c8fff2348 /contrib/tools/python3/src/Lib/unittest/main.py
parent57350d96f030db90f220ce50ee591d5c5d403df7 (diff)
downloadydb-ce1b7ca3171f9158180640c6a02a74b4afffedea.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Lib/unittest/main.py')
-rw-r--r--contrib/tools/python3/src/Lib/unittest/main.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/contrib/tools/python3/src/Lib/unittest/main.py b/contrib/tools/python3/src/Lib/unittest/main.py
index 046fbd3a45d..dd4dbf7535f 100644
--- a/contrib/tools/python3/src/Lib/unittest/main.py
+++ b/contrib/tools/python3/src/Lib/unittest/main.py
@@ -9,6 +9,7 @@ from . import loader, runner
from .signals import installHandler
__unittest = True
+_NO_TESTS_EXITCODE = 5
MAIN_EXAMPLES = """\
Examples:
@@ -66,7 +67,8 @@ class TestProgram(object):
def __init__(self, module='__main__', defaultTest=None, argv=None,
testRunner=None, testLoader=loader.defaultTestLoader,
exit=True, verbosity=1, failfast=None, catchbreak=None,
- buffer=None, warnings=None, *, tb_locals=False):
+ buffer=None, warnings=None, *, tb_locals=False,
+ durations=None):
if isinstance(module, str):
self.module = __import__(module)
for part in module.split('.')[1:]:
@@ -82,6 +84,7 @@ class TestProgram(object):
self.verbosity = verbosity
self.buffer = buffer
self.tb_locals = tb_locals
+ self.durations = durations
if warnings is None and not sys.warnoptions:
# even if DeprecationWarnings are ignored by default
# print them anyway unless other warnings settings are
@@ -178,6 +181,9 @@ class TestProgram(object):
parser.add_argument('--locals', dest='tb_locals',
action='store_true',
help='Show local variables in tracebacks')
+ parser.add_argument('--durations', dest='durations', type=int,
+ default=None, metavar="N",
+ help='Show the N slowest test cases (N=0 for all)')
if self.failfast is None:
parser.add_argument('-f', '--failfast', dest='failfast',
action='store_true',
@@ -258,9 +264,10 @@ class TestProgram(object):
failfast=self.failfast,
buffer=self.buffer,
warnings=self.warnings,
- tb_locals=self.tb_locals)
+ tb_locals=self.tb_locals,
+ durations=self.durations)
except TypeError:
- # didn't accept the tb_locals argument
+ # didn't accept the tb_locals or durations argument
testRunner = self.testRunner(verbosity=self.verbosity,
failfast=self.failfast,
buffer=self.buffer,
@@ -273,6 +280,12 @@ class TestProgram(object):
testRunner = self.testRunner
self.result = testRunner.run(self.test)
if self.exit:
- sys.exit(not self.result.wasSuccessful())
+ if self.result.testsRun == 0 and len(self.result.skipped) == 0:
+ sys.exit(_NO_TESTS_EXITCODE)
+ elif self.result.wasSuccessful():
+ sys.exit(0)
+ else:
+ sys.exit(1)
+
main = TestProgram