Skip to content

Commit 897c870

Browse files
bpo-14853: add back the stdin test, skip if stdin is redirected (GH-27694) (GH-27698)
(cherry picked from commit 8ed1833) Co-authored-by: Irit Katriel <[email protected]>
1 parent 6f4cded commit 897c870

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/test/test_file.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,22 @@ def testModeStrings(self):
153153
f.close()
154154
self.fail('%r is an invalid file mode' % mode)
155155

156+
def testStdin(self):
157+
if sys.platform == 'osf1V5':
158+
# This causes the interpreter to exit on OSF1 v5.1.
159+
self.skipTest(
160+
' sys.stdin.seek(-1) may crash the interpreter on OSF1.'
161+
' Test manually.')
162+
163+
if not sys.stdin.isatty():
164+
# Issue 14853: stdin becomes seekable when redirected to a file
165+
self.skipTest('stdin must be a TTY in this test')
166+
167+
with self.assertRaises((IOError, ValueError)):
168+
sys.stdin.seek(-1)
169+
with self.assertRaises((IOError, ValueError)):
170+
sys.stdin.truncate()
171+
156172
def testBadModeArgument(self):
157173
# verify that we get a sensible error message for bad mode argument
158174
bad_mode = "qwerty"

0 commit comments

Comments
 (0)