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.

Title: Add interactive console tests
Type: enhancement Stage: resolved
Components: Tests, Windows Versions: Python 3.7, Python 3.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: steve.dower Nosy List: eryksun, paul.moore, python-dev, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2016-09-20 17:44 by steve.dower, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit eryksun, 2016-09-20 22:46 eryksun, 2016-09-20 22:47
28217_1.patch steve.dower, 2016-09-30 17:14 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (4)
msg277049 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-09-20 17:44
We can test the interactive console by opening new console buffers (CONIN$ and CONOUT$) in the test process, then creating a subprocess with those set as the standard handles. Now we can use WriteConsoleInput from the test process to simulate the user typing at the console.

This would be useful for verifying that Unicode support works properly and that the interactive mode behaves correctly.
msg277078 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2016-09-20 22:46
Here's the ctypes code (mentioned on issue 1602) for writing to the input buffer and reading from the screen buffer. For output testing I also have a context manager to create and temporarily activate a new screen buffer with a given number of columns and rows and filled with a particular character (e.g. NUL), which makes it easier to read the output up to the current cursor position. 

Activating the new screen can be factored out if you're just testing a child writing to stdout. I added the screen activation part in order to read the output from a program that was stubbornly writing to CONOUT$, ignoring the pipe that was passed as stdout.
msg277763 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-09-30 17:14
Added my work on this so far. I've only done input testing, but that's the more important one anyway in my opinion.

Feel free to suggest more edge cases we ought to test and I'll try and get to adding them before b2.
msg277963 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-10-03 16:12
New changeset 363888141f41 by Steve Dower in branch '3.6':
Issue #28217: Adds _testconsole module to test console input. Fixes some issues found by the tests.

New changeset 3ec6a610e93e by Steve Dower in branch 'default':
Issue #28217: Adds _testconsole module to test console input.
Date User Action Args
2022-04-11 14:58:37adminsetgithub: 72404
2017-03-31 16:36:19dstufftsetpull_requests: + pull_request931
2016-10-03 16:13:41steve.dowersetstatus: open -> closed
resolution: fixed
stage: test needed -> resolved
2016-10-03 16:12:55python-devsetnosy: + python-dev
messages: + msg277963
2016-09-30 17:15:04steve.dowersetfiles: + 28217_1.patch
keywords: + patch
messages: + msg277763
2016-09-28 15:19:58steve.dowersetassignee: steve.dower
2016-09-20 22:47:45eryksunsetfiles: +
2016-09-20 22:46:24eryksunsetfiles: +
nosy: + eryksun
messages: + msg277078

2016-09-20 17:45:06steve.dowerlinkissue1602 superseder
2016-09-20 17:44:27steve.dowercreate