]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-14853: add back the stdin test, skip if stdin is redirected (GH-27694)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Mon, 9 Aug 2021 22:38:26 +0000 (23:38 +0100)
committerGitHub <noreply@github.com>
Mon, 9 Aug 2021 22:38:26 +0000 (23:38 +0100)
Lib/test/test_file.py

index fbfba64759a1e40d82023c498a23140ef7c1c982..1ec756f334d28f784beb993f9554e763d5477b8d 100644 (file)
@@ -154,6 +154,22 @@ class OtherFileTests:
                 f.close()
                 self.fail('%r is an invalid file mode' % mode)
 
+    def testStdin(self):
+        if sys.platform == 'osf1V5':
+            # This causes the interpreter to exit on OSF1 v5.1.
+            self.skipTest(
+                ' sys.stdin.seek(-1) may crash the interpreter on OSF1.'
+                ' Test manually.')
+
+        if not sys.stdin.isatty():
+            # Issue 14853: stdin becomes seekable when redirected to a file
+            self.skipTest('stdin must be a TTY in this test')
+
+        with self.assertRaises((IOError, ValueError)):
+            sys.stdin.seek(-1)
+        with self.assertRaises((IOError, ValueError)):
+            sys.stdin.truncate()
+
     def testBadModeArgument(self):
         # verify that we get a sensible error message for bad mode argument
         bad_mode = "qwerty"