diff options
Diffstat (limited to 'Lib/test/test_fileinput.py')
-rw-r--r-- | Lib/test/test_fileinput.py | 11 |
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 |