Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Prevent unittest --buffer from crashing #620

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ def __init__(self, case):

def __enter__(self):
self._raises_ctx.__enter__()
self.old_sys_stdout = sys.stdout
self.old_sys_stderr = sys.stderr
sys.stdout = self.outstream = StringIO()
sys.stderr = self.errstream = StringIO()
return self

def __exit__(self, *exc_info):
self.stdout, sys.stdout = self.outstream.getvalue(), sys.__stdout__
self.stderr, sys.stderr = self.errstream.getvalue(), sys.__stderr__
self.stdout = self.outstream.getvalue()
self.stderr = self.errstream.getvalue()
Jayman2000 marked this conversation as resolved.
Show resolved Hide resolved
sys.stdout = self.old_sys_stdout
sys.stderr = self.old_sys_stderr
return self._raises_ctx.__exit__(*exc_info)

@property
Expand Down
Loading