This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Do not skip test_curses on non-tty
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: serhiy.storchaka, twouters, vstinner
Priority: normal Keywords: patch

Created on 2020-12-30 19:06 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24009 merged serhiy.storchaka, 2020-12-30 19:11
PR 24076 merged serhiy.storchaka, 2021-01-03 14:15
PR 24078 merged serhiy.storchaka, 2021-01-03 21:43
PR 24085 merged serhiy.storchaka, 2021-01-04 09:41
Messages (10)
msg384083 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-30 19:06
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.
msg384231 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-02 17:35
New changeset 607501abb488fb37e33cf9d35260ab7baefa192f by Serhiy Storchaka in branch 'master':
bpo-42789: Don't skip curses tests on non-tty. (GH-24009)
https://github.com/python/cpython/commit/607501abb488fb37e33cf9d35260ab7baefa192f
msg384241 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-02 22:01
Buildbot failure: ARM Raspbian 3.x:
https://buildbot.python.org/all/#/builders/424/builds/658

Tests are run with env var TERM=screen.xterm-256color.

======================================================================
ERROR: test_colors_funcs (test.test_curses.TestCurses)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/lib/buildbot/workers/3.x.gps-raspbian/build/Lib/test/test_curses.py", line 316, in test_colors_funcs
    curses.pair_content(curses.COLOR_PAIRS - 1)
_curses.error: Argument 1 was out of range. (1..COLOR_PAIRS-1)
msg384242 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-02 22:03
s390x RHEL8 3.x:
https://buildbot.python.org/all/#/builders/509/builds/601

Tests run with TERM=xterm-256color.

======================================================================
ERROR: test_colors_funcs (test.test_curses.TestCurses)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/test/test_curses.py", line 316, in test_colors_funcs
    curses.pair_content(curses.COLOR_PAIRS - 1)
_curses.error: Argument 1 was out of range. (1..COLOR_PAIRS-1)

--

test.pythoninfo doesn't log anything about curses. I expected to find _curses.ncurses_version there.
msg384260 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-03 10:32
I guess I should merge a PR for issue42681 first.
msg384298 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-03 20:54
New changeset 0303008ebceb6ac6035cd9722d1393267304171d by Serhiy Storchaka in branch '3.9':
[3.9] bpo-42789: Don't skip curses tests on non-tty. (GH-24009) (GH-24076)
https://github.com/python/cpython/commit/0303008ebceb6ac6035cd9722d1393267304171d
msg384300 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-03 22:54
New changeset 645174abe0d13cce2cb339cc80b095ad484428ea by Serhiy Storchaka in branch '3.8':
[3.8] [3.9] bpo-42789: Don't skip curses tests on non-tty. (GH-24009) (GH-24076) (GH-24078)
https://github.com/python/cpython/commit/645174abe0d13cce2cb339cc80b095ad484428ea
msg384303 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-03 23:55
> Buildbot failure: ARM Raspbian 3.x: (...)

As expected, the 3.8 and 3.9 change also broke 11 buildbots (3.8 and 3.8) ;-) I understand that bpo-42681 will fix buildbots.
msg384313 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-04 09:47
On other hand, it was impossible to write correct tests for issue42681 while tests were skipped on buildbots. I spent the whole day yesterday debugging and backporting that changes (some tests failed only on one particular builtbot). So it was right to enable tests first.
msg384317 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-04 10:30
New changeset b6fc0c406e6b4b86f59b1390142f35da0e364927 by Serhiy Storchaka in branch 'master':
bpo-42789: Enable using /dev/tty in test_curses. (GH-24085)
https://github.com/python/cpython/commit/b6fc0c406e6b4b86f59b1390142f35da0e364927
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86955
2021-01-04 10:30:55serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-01-04 10:30:24serhiy.storchakasetmessages: + msg384317
2021-01-04 09:47:09serhiy.storchakasetmessages: + msg384313
2021-01-04 09:41:21serhiy.storchakasetpull_requests: + pull_request22918
2021-01-03 23:55:10vstinnersetmessages: + msg384303
2021-01-03 22:54:27serhiy.storchakasetmessages: + msg384300
2021-01-03 21:43:00serhiy.storchakasetpull_requests: + pull_request22912
2021-01-03 20:54:49serhiy.storchakasetmessages: + msg384298
2021-01-03 14:15:06serhiy.storchakasetpull_requests: + pull_request22910
2021-01-03 10:32:05serhiy.storchakasetmessages: + msg384260
2021-01-02 22:03:55vstinnersetmessages: + msg384242
2021-01-02 22:01:11vstinnersetnosy: + vstinner
messages: + msg384241
2021-01-02 17:35:18serhiy.storchakasetmessages: + msg384231
2020-12-30 19:11:47serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request22851
2020-12-30 19:06:35serhiy.storchakacreate