MCPcopy Index your code
hub / github.com/pyinvoke/invoke / shows_UnexpectedExit_str_when_streams_hidden

Method shows_UnexpectedExit_str_when_streams_hidden

tests/program.py:424–458  ·  view source on GitHub ↗
(self, mock_exit)

Source from the content-addressed store, hash-verified

422 @trap
423 @patch("invoke.program.sys.exit")
424 def shows_UnexpectedExit_str_when_streams_hidden(self, mock_exit):
425 p = Program()
426 oops = UnexpectedExit(
427 Result(
428 command="meh",
429 exited=54,
430 stdout="things!",
431 stderr="ohnoz!",
432 encoding="utf-8",
433 hide=("stdout", "stderr"),
434 )
435 )
436 p.execute = Mock(side_effect=oops)
437 p.run("myapp foo")
438 # Expect repr() of exception prints to stderr
439 # NOTE: this partially duplicates a test in runners.py; whatever.
440 stderr = sys.stderr.getvalue()
441 expected = """Encountered a bad command exit code!
442
443Command: 'meh'
444
445Exit code: 54
446
447Stdout:
448
449things!
450
451Stderr:
452
453ohnoz!
454
455"""
456 assert stderr == expected
457 # And exit with expected code (vs e.g. 1 or 0)
458 mock_exit.assert_called_with(54)
459
460 @trap
461 @patch("invoke.program.sys.exit")

Callers

nothing calls this directly

Calls 4

runMethod · 0.95
ProgramClass · 0.90
UnexpectedExitClass · 0.90
ResultClass · 0.90

Tested by

no test coverage detected