You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Here's the ctypes code (mentioned on bpo-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.
Activity
zooba commentedon Sep 20, 2016
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.
eryksun commentedon Sep 20, 2016
Here's the ctypes code (mentioned on bpo-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.
zooba commentedon Sep 30, 2016
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.
python-dev commentedon Oct 3, 2016
New changeset 363888141f41 by Steve Dower in branch '3.6':
Issue bpo-28217: Adds _testconsole module to test console input. Fixes some issues found by the tests.
https://hg.python.org/cpython/rev/363888141f41
New changeset 3ec6a610e93e by Steve Dower in branch 'default':
Issue bpo-28217: Adds _testconsole module to test console input.
https://hg.python.org/cpython/rev/3ec6a610e93e