From 8ef2842cce234ddc6f2c1158f2d9a991c304c0d3 2011-08-02 21:25:42 From: MinRK Date: 2011-08-02 21:25:42 Subject: [PATCH] strip leading 'ESC[?1034h' in tests caused by `import readline` `import readline` causes 'ESC[?1034h' to be the first output sometimes, so strip that off the front of the first line if it is found. This has been reported to RedHat in 2007, but appears to only apply to OSX 10.7 at the moment. closes gh-662 --- diff --git a/IPython/testing/tools.py b/IPython/testing/tools.py index 01882a9..4947191 100644 --- a/IPython/testing/tools.py +++ b/IPython/testing/tools.py @@ -213,7 +213,18 @@ def ipexec(fname, options=None): full_fname = os.path.join(test_dir, fname) full_cmd = '%s %s %s' % (ipython_cmd, cmdargs, full_fname) #print >> sys.stderr, 'FULL CMD:', full_cmd # dbg - return getoutputerror(full_cmd) + out = getoutputerror(full_cmd) + # `import readline` causes 'ESC[?1034h' to be the first output sometimes, + # so strip that off the front of the first line if it is found + if out: + first = out[0] + m = re.match(r'\x1b\[[^h]+h', first) + if m: + # strip initial readline escape + out = list(out) + out[0] = first[len(m.group()):] + out = tuple(out) + return out def ipexec_validate(fname, expected_out, expected_err='',