diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-06-01 22:00:29 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-06-01 22:00:29 +0300 |
commit | f018f576993c86a73f0a730ffa56e67e328c7aaf (patch) | |
tree | 4e1f40faf8bc1e8efed27925382521f01977b10c /echo.py | |
parent | 8d603a5d369178a04e099acd93de450ff351022d (diff) | |
download | fable-poc-f018f576993c86a73f0a730ffa56e67e328c7aaf.tar.gz |
Add: a second scenario
Diffstat (limited to 'echo.py')
-rw-r--r-- | echo.py | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -13,15 +13,22 @@ def assertEqual(a, b): raise Exception( 'expected {!r} == {!r}, but was disappointed'.format(a, b)) -def run_echo_without_args(): +def _run_echo(args): cmd = '/bin/echo' p = subprocess.Popen( - [cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + [cmd] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + text=True) out, err = p.communicate() context["stdout"] = out context["stderr"] = err context["exit_code"] = p.returncode +def run_echo_without_args(): + _run_echo([]) + +def run_echo_with_args(args=None): + _run_echo(args.split()) + def exit_code_is_zero(exit_code=None): exit_code = int(exit_code) assertEqual(_get("exit_code"), exit_code) @@ -29,5 +36,8 @@ def exit_code_is_zero(exit_code=None): def stdout_is_a_newline(): assertEqual(_get('stdout'), '\n') +def stdout_is_text(text=None): + assertEqual(_get('stdout'), text + '\n') + def stderr_is_empty(): assertEqual(_get('stderr'), '') |