A shell command ran to completion but exited with an unexpected exit code. Its string representation displays the following: - Command executed; - Exit code; - The last 10 lines of stdout, if it was hidden; - The last 10 lines of stderr, if it was hidden and non-empty (e.g
| 104 | |
| 105 | |
| 106 | class UnexpectedExit(Failure): |
| 107 | """ |
| 108 | A shell command ran to completion but exited with an unexpected exit code. |
| 109 | |
| 110 | Its string representation displays the following: |
| 111 | |
| 112 | - Command executed; |
| 113 | - Exit code; |
| 114 | - The last 10 lines of stdout, if it was hidden; |
| 115 | - The last 10 lines of stderr, if it was hidden and non-empty (e.g. |
| 116 | pty=False; when pty=True, stderr never happens.) |
| 117 | |
| 118 | .. versionadded:: 1.0 |
| 119 | """ |
| 120 | |
| 121 | def __str__(self) -> str: |
| 122 | stdout, stderr = self.streams_for_display() |
| 123 | command = self.result.command |
| 124 | exited = self.result.exited |
| 125 | template = """Encountered a bad command exit code! |
| 126 | |
| 127 | Command: {!r} |
| 128 | |
| 129 | Exit code: {} |
| 130 | |
| 131 | Stdout:{} |
| 132 | |
| 133 | Stderr:{} |
| 134 | |
| 135 | """ |
| 136 | return template.format(command, exited, stdout, stderr) |
| 137 | |
| 138 | def _repr(self, **kwargs: Any) -> str: |
| 139 | kwargs.setdefault("exited", self.result.exited) |
| 140 | return super()._repr(**kwargs) |
| 141 | |
| 142 | |
| 143 | class CommandTimedOut(Failure): |
no outgoing calls
no test coverage detected
searching dependent graphs…