StringIO that closes after getvalue().
| 298 | |
| 299 | |
| 300 | class ClosingStringIO(StringIO): |
| 301 | """StringIO that closes after getvalue().""" |
| 302 | |
| 303 | def getvalue(self, close=True): |
| 304 | """Get the value.""" |
| 305 | out = super().getvalue() |
| 306 | if close: |
| 307 | self.close() |
| 308 | return out |
| 309 | |
| 310 | |
| 311 | class catch_logging: |
no outgoing calls