Skip to content

Commit

Permalink
tests: Restore stdout and stderr
Browse files Browse the repository at this point in the history
Before this commit, test_run_default_format_output_in_tty() changed the
values of sys.stdout and sys.stderr, but it would never change them
back. This commit makes sure that they get changed back.

At the moment, this commit doesn’t make a user-visible difference. A
future commit will add a new test named test_ignored_from_file_with_multiple_encodings().
That new test requires stdout and stderr to be restored, or else it will
fail.
  • Loading branch information
Jayman2000 committed Jan 13, 2024
1 parent 7b41f65 commit b6cf981
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ def test_run_default_format_output_in_tty(self):
path = os.path.join(self.wd, 'a.yaml')

# Create a pseudo-TTY and redirect stdout to it
old_stdout, old_stderr = sys.stdout, sys.stderr
master, slave = pty.openpty()
sys.stdout = sys.stderr = os.fdopen(slave, 'w')

Expand All @@ -535,6 +536,7 @@ def test_run_default_format_output_in_tty(self):
sys.stdout.close()
sys.stderr.close()
output.close()
sys.stdout, sys.stderr = old_stdout, old_stderr

self.assertEqual(out, (
f'\033[4m{path}\033[0m\n'
Expand Down

0 comments on commit b6cf981

Please sign in to comment.