summaryrefslogtreecommitdiff
path: root/Lib/test/test_fileinput.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-01-02 15:43:44 -0500
committerR David Murray <rdmurray@bitdance.com>2016-01-02 15:43:44 -0500
commit01759d55547c4f39d451f4063d51fd309744f3ea (patch)
tree8574fcc248b0b6143ccfd65a438096ecf216bdca /Lib/test/test_fileinput.py
parent5b3455c793228b6f323dce18551a81f87e46fbb7 (diff)
parent830207e8f32df949ec35e2e7f5afe98975e262c9 (diff)
downloadcpython-git-01759d55547c4f39d451f4063d51fd309744f3ea.tar.gz
Merge: #22709: Use stdin as-is if it does not have a buffer attribute.
Diffstat (limited to 'Lib/test/test_fileinput.py')
-rw-r--r--Lib/test/test_fileinput.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
index 4765a056f6..91c11668bd 100644
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -240,6 +240,17 @@ class FileInputTests(unittest.TestCase):
lines = list(fi)
self.assertEqual(lines, [b'spam, bacon, sausage, and spam'])
+ def test_detached_stdin_binary_mode(self):
+ orig_stdin = sys.stdin
+ try:
+ sys.stdin = BytesIO(b'spam, bacon, sausage, and spam')
+ self.assertFalse(hasattr(sys.stdin, 'buffer'))
+ fi = FileInput(files=['-'], mode='rb')
+ lines = list(fi)
+ self.assertEqual(lines, [b'spam, bacon, sausage, and spam'])
+ finally:
+ sys.stdin = orig_stdin
+
def test_file_opening_hook(self):
try:
# cannot use openhook and inplace mode