summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJendrik Seipp <jendrikseipp@gmail.com>2020-01-01 22:21:43 (GMT)
committerAntoine Pitrou <antoine@python.org>2020-01-01 22:21:43 (GMT)
commit5b9077134cd0535f21905d5f5195847526cac99c (patch)
tree4bed1fd2a5350e003816b1cc05a474d903efedcc /Lib
parent46abfc1416ff8e450999611ef8f231ff871ab133 (diff)
downloadcpython-5b9077134cd0535f21905d5f5195847526cac99c.zip
cpython-5b9077134cd0535f21905d5f5195847526cac99c.tar.gz
cpython-5b9077134cd0535f21905d5f5195847526cac99c.tar.bz2
bpo-13601: always use line-buffering for sys.stderr (GH-17646)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_cmd_line.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index 4781002..ee96473 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -6,6 +6,7 @@ import os
import subprocess
import sys
import tempfile
+import textwrap
import unittest
from test import support
from test.support.script_helper import (
@@ -219,6 +220,21 @@ class CmdLineTest(unittest.TestCase):
)
check_output(text)
+ def test_non_interactive_output_buffering(self):
+ code = textwrap.dedent("""
+ import sys
+ out = sys.stdout
+ print(out.isatty(), out.write_through, out.line_buffering)
+ err = sys.stderr
+ print(err.isatty(), err.write_through, err.line_buffering)
+ """)
+ args = [sys.executable, '-c', code]
+ proc = subprocess.run(args, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, text=True, check=True)
+ self.assertEqual(proc.stdout,
+ 'False False False\n'
+ 'False False True\n')
+
def test_unbuffered_output(self):
# Test expected operation of the '-u' switch
for stream in ('stdout', 'stderr'):