From 7ba8cdc31c2704f3c9017fb66ce14fc0983d68f8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 6 Jan 2015 12:39:45 +0100 Subject: [PATCH] Issue #23168: skip sys.stdin.seek() test if stdin is not a TTY --- Lib/test/test_file2k.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py index 3803950811..c5dd1a6b5a 100644 --- a/Lib/test/test_file2k.py +++ b/Lib/test/test_file2k.py @@ -230,14 +230,20 @@ class OtherFileTests(unittest.TestCase): 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): -- 2.50.1