Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
  • Loading branch information
3 people authored Jan 13, 2025
commit 7debe697b40b26d6b7d4f410b6a287779c78c7dd
3 changes: 0 additions & 3 deletions Lib/_colorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class ANSIColors:


def get_colors(colorize: bool = False, *, file=None) -> ANSIColors:
if file is None:
file = sys.stdout

if colorize or can_colorize(file=file):
return ANSIColors()
else:
Expand Down
4 changes: 2 additions & 2 deletions Lib/unittest/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def _exc_info_to_string(self, err, test):
capture_locals=self.tb_locals, compact=True)
from _colorize import can_colorize

file = self.stream if hasattr(self, "stream") else None
msgLines = list(tb_e.format(colorize=can_colorize(file=file)))
colorize = hasattr(self, "stream") and can_colorize(self.stream)
msgLines = list(tb_e.format(colorize=colorize)

if self.buffer:
output = sys.stdout.getvalue()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default to stdout isatty for colour detection instead of stderr. Patch by
Default to stdout isatty for color detection instead of stderr. Patch by
Hugo van Kemenade.