diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-08 23:11:00 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-08 23:11:00 (GMT) |
commit | 81a1fa5c778c4b33ca71fcf25155189545870aab (patch) | |
tree | e69b9cf1980d95f467633769939fbd4b246f277d /Lib/test/test_os.py | |
parent | cfade36227ce9d986da988c14dd80e21cf485400 (diff) | |
download | cpython-81a1fa5c778c4b33ca71fcf25155189545870aab.zip cpython-81a1fa5c778c4b33ca71fcf25155189545870aab.tar.gz cpython-81a1fa5c778c4b33ca71fcf25155189545870aab.tar.bz2 |
get_terminal_size() can also fail with ENOTTY if the fd is not connected to a terminal.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index b9eb290..c5dbb95 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1851,7 +1851,7 @@ class TermsizeTests(unittest.TestCase): try: size = os.get_terminal_size() except OSError as e: - if e.errno == errno.EINVAL or sys.platform == "win32": + if sys.platform == "win32" or e.errno in (errno.EINVAL, errno.ENOTTY): # Under win32 a generic OSError can be thrown if the # handle cannot be retrieved self.skipTest("failed to query terminal size") @@ -1873,7 +1873,14 @@ class TermsizeTests(unittest.TestCase): self.skipTest("stty invocation failed") expected = (int(size[1]), int(size[0])) # reversed order - actual = os.get_terminal_size(sys.__stdin__.fileno()) + try: + actual = os.get_terminal_size(sys.__stdin__.fileno()) + except OSError as e: + if sys.platform == "win32" or e.errno in (errno.EINVAL, errno.ENOTTY): + # Under win32 a generic OSError can be thrown if the + # handle cannot be retrieved + self.skipTest("failed to query terminal size") + raise self.assertEqual(expected, actual) |