Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-14853: add back the stdin test, skip if stdin is redirected #27694

Merged
merged 2 commits into from Aug 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions Lib/test/test_file.py
Expand Up @@ -154,6 +154,22 @@ def testModeStrings(self):
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"
Expand Down