Skip to content

Commit 8ed1833

Browse files
authored
bpo-14853: add back the stdin test, skip if stdin is redirected (GH-27694)
1 parent c5c5326 commit 8ed1833

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
@@ -154,6 +154,22 @@ def testModeStrings(self):
154154
f.close()
155155
self.fail('%r is an invalid file mode' % mode)
156156

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

0 commit comments

Comments
 (0)