gh-131178: Update help message for timeit CLI (#131326)

This commit is contained in:
Semyon Moroz 2025-03-30 15:19:38 +04:00 committed by GitHub
parent eaffc34d3c
commit 55150a79ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 5 deletions

View file

@ -297,9 +297,7 @@ class TestTimeit(unittest.TestCase):
@unittest.skipIf(sys.flags.optimize >= 2, "need __doc__") @unittest.skipIf(sys.flags.optimize >= 2, "need __doc__")
def test_main_help(self): def test_main_help(self):
s = self.run_main(switches=['-h']) s = self.run_main(switches=['-h'])
# Note: It's not clear that the trailing space was intended as part of self.assertEqual(s, timeit.__doc__)
# the help text, but since it's there, check for it.
self.assertEqual(s, timeit.__doc__ + ' ')
def test_main_verbose(self): def test_main_verbose(self):
s = self.run_main(switches=['-v']) s = self.run_main(switches=['-v'])

View file

@ -44,7 +44,6 @@ Functions:
timeit(string, string) -> float timeit(string, string) -> float
repeat(string, string) -> list repeat(string, string) -> list
default_timer() -> float default_timer() -> float
""" """
import gc import gc
@ -302,7 +301,7 @@ def main(args=None, *, _wrap_timer=None):
precision += 1 precision += 1
verbose += 1 verbose += 1
if o in ("-h", "--help"): if o in ("-h", "--help"):
print(__doc__, end=' ') print(__doc__, end="")
return 0 return 0
setup = "\n".join(setup) or "pass" setup = "\n".join(setup) or "pass"