[New-bugs-announce] [issue42789] Do not skip test_curses on non-tty

Serhiy Storchaka report at bugs.python.org
Wed Dec 30 14:06:35 EST 2020

New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

Currently many tests in test_curses are skipped if sys.__stdout__ is not attached to terminal. All tests are ran only when run them manually, and without using pager. This leads to passing bugs, like in issue42694.

The proposed PR makes tests always ran. If __stdout__ is not attached to terminal, it tries to attach it to terminal, using __stderr__ if it is attached to terminal, or opening /dev/tty. If neither __stdout__ nor __stderr__ are attached to terminal, it tries to use temporary file, but some functions do not work in this case and will be untested.

It could be better to use os.openpty(), but too many curses outputs can overflow the buffer (2 KiB) and cause the test and all subsequent tests to fail. Currently all tests are passed if use os.openpty(), but I afraid that adding more tests will overflow the buffer and it will confuse future developers. My attempts to solve this issue was unsuccessful for that time, so I left more complicated and less flexible, but more reliable solution.

components: Tests
messages: 384083
nosy: serhiy.storchaka, twouters
priority: normal
severity: normal
status: open
title: Do not skip test_curses on non-tty
type: enhancement
versions: Python 3.10, Python 3.8, Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list