Skip to content

Commit a3132ed

Browse files
committed
Issue #23168: skip sys.stdin.seek() test if stdin is not a TTY
1 parent d30a381 commit a3132ed

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

Lib/test/test_file2k.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,20 @@ def testModeStrings(self):
230230
else:
231231
f.close()
232232

233-
def testStdin(self):
234-
# This causes the interpreter to exit on OSF1 v5.1.
235-
if sys.platform != 'osf1V5':
236-
self.assertRaises(IOError, sys.stdin.seek, -1)
237-
else:
238-
print >>sys.__stdout__, (
239-
' Skipping sys.stdin.seek(-1), it may crash the interpreter.'
240-
' Test manually.')
233+
def testStdinSeek(self):
234+
if sys.platform == 'osf1V5':
235+
# This causes the interpreter to exit on OSF1 v5.1.
236+
self.skipTest('Skipping sys.stdin.seek(-1), it may crash '
237+
'the interpreter. Test manually.')
238+
239+
if not sys.stdin.isatty():
240+
# Issue #23168: if stdin is redirected to a file, stdin becomes
241+
# seekable
242+
self.skipTest('stdin must be a TTY in this test')
243+
244+
self.assertRaises(IOError, sys.stdin.seek, -1)
245+
246+
def testStdinTruncate(self):
241247
self.assertRaises(IOError, sys.stdin.truncate)
242248

243249
def testUnicodeOpen(self):

0 commit comments

Comments
 (0)