Skip to content

Commit

Permalink
Rename parse_args to _parse_args
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed May 2, 2024
1 parent 5a487bb commit 15dec31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Lib/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ def _test(N=10_000):
# -------------- command-line interface ----------------


def parse_args(arg_list: list[str] | None):
def _parse_args(arg_list: list[str] | None):
import argparse
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter)
Expand Down Expand Up @@ -1028,7 +1028,7 @@ def parse_args(arg_list: list[str] | None):


def main(arg_list: list[str] | None = None) -> int | str:
args, help_text = parse_args(arg_list)
args, help_text = _parse_args(arg_list)

# Explicit arguments
if args.choice:
Expand Down
12 changes: 6 additions & 6 deletions Lib/test/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,27 +1400,27 @@ def test_after_fork(self):

class CommandLineTest(unittest.TestCase):
def test_parse_args(self):
args, help_text = random.parse_args(shlex.split("--choice a b c"))
args, help_text = random._parse_args(shlex.split("--choice a b c"))
self.assertEqual(args.choice, ["a", "b", "c"])
self.assertTrue(help_text.startswith("usage: "))

args, help_text = random.parse_args(shlex.split("--integer 5"))
args, help_text = random._parse_args(shlex.split("--integer 5"))
self.assertEqual(args.integer, 5)
self.assertTrue(help_text.startswith("usage: "))

args, help_text = random.parse_args(shlex.split("--float 2.5"))
args, help_text = random._parse_args(shlex.split("--float 2.5"))
self.assertEqual(args.float, 2.5)
self.assertTrue(help_text.startswith("usage: "))

args, help_text = random.parse_args(shlex.split("a b c"))
args, help_text = random._parse_args(shlex.split("a b c"))
self.assertEqual(args.input, ["a", "b", "c"])
self.assertTrue(help_text.startswith("usage: "))

args, help_text = random.parse_args(shlex.split("5"))
args, help_text = random._parse_args(shlex.split("5"))
self.assertEqual(args.input, ["5"])
self.assertTrue(help_text.startswith("usage: "))

args, help_text = random.parse_args(shlex.split("2.5"))
args, help_text = random._parse_args(shlex.split("2.5"))
self.assertEqual(args.input, ["2.5"])
self.assertTrue(help_text.startswith("usage: "))

Expand Down

0 comments on commit 15dec31

Please sign in to comment.