(invocation, out, program=None, test="equals")
| 34 | # stdout, allowing the tests themselves to assert more naturally |
| 35 | @trap |
| 36 | def 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 | |
| 54 | def faux_v1_env(): |
no test coverage detected