MCPcopy
hub / github.com/fabric/fabric / expect

Function expect

tests/_util.py:36–51  ·  view source on GitHub ↗
(invocation, out, program=None, test="equals")

Source from the content-addressed store, hash-verified

34# stdout, allowing the tests themselves to assert more naturally
35@trap
36def expect(invocation, out, program=None, test="equals"):
37 if program is None:
38 program = make_program()
39 program.run("fab {}".format(invocation), exit=False)
40 output = sys.stdout.getvalue()
41 if test == "equals":
42 assert output == out
43 elif test == "contains":
44 assert out in output
45 elif test == "regex":
46 assert re.match(out, output)
47 else:
48 err = "Don't know how to expect that <stdout> {} <expected>!"
49 assert False, err.format(test)
50 # Safety check: no stderr
51 assert not sys.stderr.getvalue()
52
53
54def faux_v1_env():

Calls 2

make_programFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected