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
|
import subprocess
def _runcmd(ctx, argv):
p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate("")
ctx['stdout'] = stdout
ctx['stderr'] = stderr
ctx['exit'] = p.returncode
def run_echo_without_args(ctx):
_runcmd(ctx, ['echo'])
def run_echo_with_args(ctx, args=None):
_runcmd(ctx, ['echo', args])
def exit_code_is(ctx, exit_code=None):
assert_eq(ctx['exit'], int(exit_code))
def stdout_is_a_newline(ctx):
assert_eq(ctx['stdout'], b'\n')
def stdout_is_text(ctx, text=None):
text += '\n'
text = text.encode()
assert_eq(ctx['stdout'], text)
def stderr_is_empty(ctx):
assert_eq(ctx['stderr'], b'')
|