1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
"""Tests of running a program that uses command line arguments.
"""
import sys
import subprocess
def run(*args):
proc = subprocess.run(
[
sys.executable,
"-m",
"friendly_traceback",
"tests/adder.py",
"--",
*args,
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
check=False,
)
return proc.stdout
def test_args_float():
result = run("1", "2.5", "3")
assert "The sum is 6.5." in result
def test_args_to_int():
result = run("1", "2.5", "3", "--to_int")
assert "The sum is 6." in result
|