Issue #23168: skip sys.stdin.seek() test if stdin is not a TTY
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py
index 3803950..c5dd1a6 100644
--- a/Lib/test/test_file2k.py
+++ b/Lib/test/test_file2k.py
@@ -230,14 +230,20 @@
else:
f.close()
- def testStdin(self):
- # This causes the interpreter to exit on OSF1 v5.1.
- if sys.platform != 'osf1V5':
- self.assertRaises(IOError, sys.stdin.seek, -1)
- else:
- print >>sys.__stdout__, (
- ' Skipping sys.stdin.seek(-1), it may crash the interpreter.'
- ' Test manually.')
+ def testStdinSeek(self):
+ if sys.platform == 'osf1V5':
+ # This causes the interpreter to exit on OSF1 v5.1.
+ self.skipTest('Skipping sys.stdin.seek(-1), it may crash '
+ 'the interpreter. Test manually.')
+
+ if not sys.stdin.isatty():
+ # Issue #23168: if stdin is redirected to a file, stdin becomes
+ # seekable
+ self.skipTest('stdin must be a TTY in this test')
+
+ self.assertRaises(IOError, sys.stdin.seek, -1)
+
+ def testStdinTruncate(self):
self.assertRaises(IOError, sys.stdin.truncate)
def testUnicodeOpen(self):