| 109 | |
| 110 | |
| 111 | class Capture: |
| 112 | def __init__(self, capfd): |
| 113 | self.capfd = capfd |
| 114 | self.out = "" |
| 115 | self.err = "" |
| 116 | |
| 117 | def __enter__(self): |
| 118 | self.capfd.readouterr() |
| 119 | return self |
| 120 | |
| 121 | def __exit__(self, *args): |
| 122 | self.out, self.err = self.capfd.readouterr() |
| 123 | |
| 124 | __hash__ = None |
| 125 | |
| 126 | def __eq__(self, other): |
| 127 | a = Output(self.out) |
| 128 | b = other |
| 129 | if a == b: |
| 130 | return True |
| 131 | self.explanation = a.explanation |
| 132 | return False |
| 133 | |
| 134 | def __str__(self): |
| 135 | return self.out |
| 136 | |
| 137 | def __contains__(self, item): |
| 138 | return item in self.out |
| 139 | |
| 140 | @property |
| 141 | def unordered(self): |
| 142 | return Unordered(self.out) |
| 143 | |
| 144 | @property |
| 145 | def stderr(self): |
| 146 | return Output(self.err) |
| 147 | |
| 148 | |
| 149 | @pytest.fixture |