summaryrefslogtreecommitdiff
path: root/tests/getch.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/getch.py')
-rwxr-xr-xtests/getch.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/getch.py b/tests/getch.py
index 41e3224..a362e52 100755
--- a/tests/getch.py
+++ b/tests/getch.py
@@ -18,6 +18,7 @@ PEXPECT LICENSE
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
'''
+from __future__ import print_function
import sys, tty, termios
if hasattr(sys.stdin, 'buffer'):
@@ -27,13 +28,13 @@ else:
stdin = sys.stdin
def main():
- print('READY')
+ print('READY', end='\r\n')
while True:
try:
val = ord(stdin.read(1))
except KeyboardInterrupt:
val = 3
- sys.stdout.write('%d<STOP>\r\n' % (val,))
+ print('%d<STOP>' % (val,), end='\r\n')
if val == 0:
# StopIteration equivalent is ctrl+' ' (\x00, NUL)
break
@@ -46,3 +47,4 @@ if __name__ == '__main__':
main()
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
+ sys.stdout.flush()