From faff3e605b2e1d6d30d3f9ded95473ccfbb8daf0 Mon Sep 17 00:00:00 2001 From: Jeff Quast Date: Fri, 18 Sep 2015 12:38:58 -0700 Subject: Allow {p}.interact(escape_character=None) For those who wish to disable the ability to escape using escape_character until normal process termination, they may now set the value of escape_character to None. Some of the related docstring on escape_character was made more brief and clear about its related value behavior. This closes #131 #132 #167 --- tests/interact.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/interact.py') diff --git a/tests/interact.py b/tests/interact.py index 9f8e672..2c1c1b7 100755 --- a/tests/interact.py +++ b/tests/interact.py @@ -33,7 +33,10 @@ import sys def main(): p = pexpect.spawn(sys.executable + ' echo_w_prompt.py', env=no_coverage_env()) - p.interact() + escape_character = chr(29) # default matches api + if len(sys.argv) > 1 and sys.argv[1] == '--no-escape': + escape_character = None + p.interact(escape_character=escape_character) print("Escaped interact") if __name__ == '__main__': -- cgit v1.2.1 From dd5cb38f555bf5861e0af33eae8f83a2a6e1e71c Mon Sep 17 00:00:00 2001 From: Jeff Quast Date: Sun, 20 Sep 2015 16:42:12 -0700 Subject: interact tests: prefer getch over echo_w_prompt this ensures more reliable clean exit, as is necessary in negative test for interact(escape_character=None) --- tests/interact.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tests/interact.py') diff --git a/tests/interact.py b/tests/interact.py index 2c1c1b7..a839e95 100755 --- a/tests/interact.py +++ b/tests/interact.py @@ -31,12 +31,21 @@ import sys def main(): - p = pexpect.spawn(sys.executable + ' echo_w_prompt.py', + p = pexpect.spawn('{sys.executable} getch.py'.format(sys=sys), env=no_coverage_env()) - escape_character = chr(29) # default matches api - if len(sys.argv) > 1 and sys.argv[1] == '--no-escape': + + # defaults matches api + escape_character = chr(29) + encoding = None + + if len(sys.argv) > 1 and '--no-escape' in sys.argv: escape_character = None + + if len(sys.argv) > 1 and '--utf8' in sys.argv: + encoding = 'utf8' + p.interact(escape_character=escape_character) + print("Escaped interact") if __name__ == '__main__': -- cgit v1.2.1