Skip to content

Loading…

frontend test tweaks #1996

Merged
merged 4 commits into from

3 participants

@minrk
IPython member

add some encoding to readline history tests that would fail in casting locales (ascii), so that the expected output really matches what should happen.

also relaxes a few timeouts in another test, which were seen to fail while poking around, to avoid spurious failures.

closes #1589

minrk added some commits
@minrk minrk relax timeouts in pexpect console-frontend test
avoid false-failures due to slow subprocess startup
ed4be7d
@minrk minrk match encoding in rlhistory tests
addresses mismatched comparison when locale cannot handle unicode (e.g. ascii)

closes #1589
c262f67
@minrk minrk specify encoding when opening file in test_history
fixes error when running in ASCII locale
93f5f3d
@minrk
IPython member

Test results for commit 93f5f3d merged into master
Platform: darwin

  • python2.6: OK (libraries not available: cython matplotlib oct2py pygments pymongo qt rpy2 tornado wx wx.aui)
  • python2.7: OK (libraries not available: oct2py wx wx.aui)
  • python3.2: OK (libraries not available: cython matplotlib oct2py pymongo qt rpy2 wx wx.aui)

Not available for testing: python3.1

@minrk
IPython member

The above test_pr was run in an ASCII locale on OS X, which revealed another py3-specific test failure due to ascii default encoding.

@cdeil

Test results for commit 8c11e5c merged into master
Platform: darwin

Not available for testing: python2.6, python3.1

@bfroehle

Speaking of frontend tests, I've been seeing this one recently. It's not causing anything to fail, however...

**********************************************************************
IPython test group: IPython.frontend
..............................
----------------------------------------------------------------------
Ran 30 tests in 2.755s

OK
Traceback (most recent call last):
  File "/home/bfroehle/src/ipython/IPython/frontend/qt/console/completion_html.py", line 152, in eventFilter
    if obj == self._text_edit:
AttributeError: 'CompletionHtml' object has no attribute '_text_edit'
@minrk
IPython member

interesting - I've never seen that error, and from the code, it makes no sense at all for it to happen - the event filter is registered after the attribute is assigned. It could be a garbage collection issue on exit, where the event filter is still registered, but the object has started to be deleted.

@bfroehle
@minrk
IPython member

I wrote, but apparently failed to post, a note about @cdeil's test_pr run: I believe all failures listed are due to libedit, and should not be considered real failures (libedit is fully expected to break all kinds of stuff). I can confirm that an ASCII locale no longer fails (I could reproduce exactly the failures reported in #1589, and they are fixed).

Getting virtualenv to install the right readline is a bit of a pain, and I don't quite remember how to do it.

@minrk minrk merged commit 3c2ce20 into ipython:master
@minrk minrk deleted the minrk:ascii branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 21, 2012
  1. @minrk

    relax timeouts in pexpect console-frontend test

    minrk committed
    avoid false-failures due to slow subprocess startup
  2. @minrk

    match encoding in rlhistory tests

    minrk committed
    addresses mismatched comparison when locale cannot handle unicode (e.g. ascii)
    
    closes #1589
  3. @minrk

    specify encoding when opening file in test_history

    minrk committed
    fixes error when running in ASCII locale
  4. @minrk

    add encoding to sys_info

    minrk committed
View
2 IPython/core/tests/test_history.py
@@ -93,7 +93,7 @@ def test_history():
# Cross testing: check that magic %save can get previous session.
testfilename = os.path.realpath(os.path.join(tmpdir, "test.py"))
ip.magic("save " + testfilename + " ~1/1-3")
- with py3compat.open(testfilename) as testfile:
+ with py3compat.open(testfilename, encoding='utf-8') as testfile:
nt.assert_equal(testfile.read(),
u"# coding: utf-8\n" + u"\n".join(hist))
View
8 IPython/frontend/terminal/console/tests/test_console.py
@@ -44,16 +44,16 @@ def test_console_starts():
raise SkipTest("Could not determine ipython command")
p = pexpect.spawn(ipython_cmd, args=['console', '--colors=NoColor'])
- idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=4)
+ idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=15)
nt.assert_equals(idx, 0, "expected in prompt")
p.sendline('5')
- idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=1)
+ idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=5)
nt.assert_equals(idx, 0, "expected out prompt")
- idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=1)
+ idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=5)
nt.assert_equals(idx, 0, "expected second in prompt")
# send ctrl-D;ctrl-D to exit
p.sendeof()
p.sendeof()
- p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=1)
+ p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=5)
if p.isalive():
p.terminate()
View
11 IPython/frontend/terminal/tests/test_interactivshell.py
@@ -19,6 +19,7 @@
import unittest
from IPython.testing.decorators import skipif
+from IPython.utils import py3compat
class InteractiveShellTestCase(unittest.TestCase):
def rl_hist_entries(self, rl, n):
@@ -124,7 +125,10 @@ def test_replace_multiline_hist_replaces_twice(self):
self.assertEquals(ip.readline.get_current_history_length(),
hlen_b4_cell)
hist = self.rl_hist_entries(ip.readline, 3)
- self.assertEquals(hist, ['line0', 'l€ne1\nline2', 'l€ne3\nline4'])
+ expected = [u'line0', u'l€ne1\nline2', u'l€ne3\nline4']
+ # perform encoding, in case of casting due to ASCII locale
+ expected = [ py3compat.unicode_to_str(e) for e in expected ]
+ self.assertEquals(hist, expected)
@skipif(not get_ipython().has_readline, 'no readline')
@@ -158,4 +162,7 @@ def test_replace_multiline_hist_replaces_empty_line(self):
hlen_b4_cell)
hist = self.rl_hist_entries(ip.readline, 4)
# expect no empty cells in history
- self.assertEquals(hist, ['line0', 'l€ne1\nline2', 'l€ne3', 'line4'])
+ expected = [u'line0', u'l€ne1\nline2', u'l€ne3', u'line4']
+ # perform encoding, in case of casting due to ASCII locale
+ expected = [ py3compat.unicode_to_str(e) for e in expected ]
+ self.assertEquals(hist, expected)
View
3 IPython/utils/sysinfo.py
@@ -23,7 +23,7 @@
from ConfigParser import ConfigParser
from IPython.core import release
-from IPython.utils import py3compat, _sysinfo
+from IPython.utils import py3compat, _sysinfo, encoding
#-----------------------------------------------------------------------------
# Code
@@ -91,6 +91,7 @@ def pkg_info(pkg_path):
sys_platform=sys.platform,
platform=platform.platform(),
os_name=os.name,
+ default_encoding=encoding.DEFAULT_ENCODING,
)
Something went wrong with that request. Please try again.