File: test_source_with_args.py

package info (click to toggle)
python-friendly-traceback 0.7.62%2Bgit20240811.d7dbff6-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,264 kB
  • sloc: python: 21,500; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 665 bytes parent folder | download
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