diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2021-08-09 22:38:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-09 22:38:26 (GMT) |
commit | 8ed183391241f0c73e7ba7f42b1d49fc02985f7b (patch) | |
tree | e236167aedcc807bc158a73382cd3d23548c108f /Lib/test/test_file.py | |
parent | c5c5326d4799fe4ae566aff32ed3461af95859cc (diff) | |
download | cpython-8ed183391241f0c73e7ba7f42b1d49fc02985f7b.zip cpython-8ed183391241f0c73e7ba7f42b1d49fc02985f7b.tar.gz cpython-8ed183391241f0c73e7ba7f42b1d49fc02985f7b.tar.bz2 |
bpo-14853: add back the stdin test, skip if stdin is redirected (GH-27694)
Diffstat (limited to 'Lib/test/test_file.py')
-rw-r--r-- | Lib/test/test_file.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index fbfba64..1ec756f 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -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" |