help="print a random integer between 1 and N inclusive")
group.add_argument(
"-f", "--float", type=float, metavar="N",
- help="print a random floating-point number between 1 and N inclusive")
+ help="print a random floating-point number between 0 and N inclusive")
group.add_argument(
"--test", type=int, const=10_000, nargs="?",
help=argparse.SUPPRESS)
return randint(1, args.integer)
if args.float is not None:
- return uniform(1, args.float)
+ return uniform(0, args.float)
if args.test:
_test(args.test)
try:
# Is it a float?
val = float(val)
- return uniform(1, val)
+ return uniform(0, val)
except ValueError:
# Split in case of space-separated string: "a b c"
return choice(val.split())
("'a a' 'b b' 'c c'", "b b"),
("--integer 5", 4),
("5", 4),
- ("--float 2.5", 2.266632777287572),
- ("2.5", 2.266632777287572),
+ ("--float 2.5", 2.1110546288126204),
+ ("2.5", 2.1110546288126204),
]:
random.seed(0)
self.assertEqual(random.main(shlex.split(command)), expected)