Skip to content

Commit e2e6a8c

Browse files
committed
Fix for --junit-xml
1 parent 2dff5cd commit e2e6a8c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_support.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ def test_get_attribute(self):
9797
self.assertRaises(unittest.SkipTest, support.get_attribute, self, "foo")
9898

9999
def test_get_original_stdout(self):
100-
self.assertEqual(support.get_original_stdout(), sys.stdout)
100+
if isinstance(sys.stdout, io.StringIO):
101+
# gh-55258: When --junit-xml is used, stdout is a StringIO:
102+
# use sys.__stdout__ in this case.
103+
self.assertEqual(support.get_original_stdout(), sys.__stdout__)
104+
else:
105+
self.assertEqual(support.get_original_stdout(), sys.stdout)
101106

102107
def test_unload(self):
103108
import sched # noqa: F401

0 commit comments

Comments
 (0)