##// END OF EJS Templates
Merge with Fernando's trunk-dev.
Merge with Fernando's trunk-dev.

File last commit:

r1614:9dcfcfc5
r1708:058a9eb3 merge
Show More
test_frontendbase.py
155 lines | 5.0 KiB | text/x-python | PythonLexer
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 # encoding: utf-8
"""This file contains unittests for the frontendbase module."""
__docformat__ = "restructuredtext en"
Barry Wark
pep8 compliance, first pass
r1291 #---------------------------------------------------------------------------
# Copyright (C) 2008 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Imports
#---------------------------------------------------------------------------
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
import unittest
Brian Granger
Changed a bunch of modules to NOT have the x permission bit set.
r1554
try:
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 from IPython.frontend.asyncfrontendbase import AsyncFrontEndBase
from IPython.frontend import frontendbase
from IPython.kernel.engineservice import EngineService
Brian Granger
Changed a bunch of modules to NOT have the x permission bit set.
r1554 except ImportError:
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 import nose
raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing a nasty bug in test_frontend.py that was leading to all sorts...
r1614 from IPython.testing.decorators import skip
Gael Varoquaux
More tests for frontends.
r1457 class FrontEndCallbackChecker(AsyncFrontEndBase):
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 """FrontEndBase subclass for checking callbacks"""
def __init__(self, engine=None, history=None):
Barry Wark
pep8 compliance, first pass
r1291 super(FrontEndCallbackChecker, self).__init__(engine=engine,
history=history)
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 self.updateCalled = False
self.renderResultCalled = False
self.renderErrorCalled = False
Brian Granger
Changed a bunch of modules to NOT have the x permission bit set.
r1554
Barry Wark
updates for frontendbase API. Cocoa plugin functional in Objective-C app
r1303 def update_cell_prompt(self, result, blockID=None):
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 self.updateCalled = True
return result
Brian Granger
Changed a bunch of modules to NOT have the x permission bit set.
r1554
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 def render_result(self, result):
self.renderResultCalled = True
return result
def render_error(self, failure):
self.renderErrorCalled = True
return failure
Barry Wark <barrywarkatgmaildotcom>
renamed AsynchronousFrontEndBase to AsyncFrontEndBase
r1315 class TestAsyncFrontendBase(unittest.TestCase):
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 def setUp(self):
"""Setup the EngineService and FrontEndBase"""
self.fb = FrontEndCallbackChecker(engine=EngineService())
Barry Wark
CammelCase fixed
r1282 def test_implements_IFrontEnd(self):
Barry Wark
pep8 compliance, first pass
r1291 assert(frontendbase.IFrontEnd.implementedBy(
Gael Varoquaux
More tests for frontends.
r1457 AsyncFrontEndBase))
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Barry Wark
CammelCase fixed
r1282 def test_is_complete_returns_False_for_incomplete_block(self):
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 """"""
block = """def test(a):"""
assert(self.fb.is_complete(block) == False)
Barry Wark
CammelCase fixed
r1282 def test_is_complete_returns_True_for_complete_block(self):
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 """"""
block = """def test(a): pass"""
assert(self.fb.is_complete(block))
block = """a=3"""
assert(self.fb.is_complete(block))
Barry Wark
CammelCase fixed
r1282 def test_blockID_added_to_result(self):
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 block = """3+3"""
d = self.fb.execute(block, blockID='TEST_ID')
d.addCallback(self.checkBlockID, expected='TEST_ID')
Barry Wark
added blockID for failures (special case)
r1283 def test_blockID_added_to_failure(self):
Brian E Granger
Fixing more tests and examples after the task, map and @parallel work.
r1396 block = "raise Exception()"
Barry Wark
added blockID for failures (special case)
r1283
d = self.fb.execute(block,blockID='TEST_ID')
d.addErrback(self.checkFailureID, expected='TEST_ID')
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 def checkBlockID(self, result, expected=""):
assert(result['blockID'] == expected)
Barry Wark
added blockID for failures (special case)
r1283 def checkFailureID(self, failure, expected=""):
assert(failure.blockID == expected)
Barry Wark
CammelCase fixed
r1282 def test_callbacks_added_to_execute(self):
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 """test that
update_cell_prompt
render_result
are added to execute request
"""
d = self.fb.execute("10+10")
d.addCallback(self.checkCallbacks)
def checkCallbacks(self, result):
assert(self.fb.updateCalled)
assert(self.fb.renderResultCalled)
Brian Granger
Fixing a nasty bug in test_frontend.py that was leading to all sorts...
r1614 @skip("This test fails and lead to an unhandled error in a Deferred.")
Barry Wark
CammelCase fixed
r1282 def test_error_callback_added_to_execute(self):
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 """test that render_error called on execution error"""
d = self.fb.execute("raise Exception()")
d.addCallback(self.checkRenderError)
def checkRenderError(self, result):
assert(self.fb.renderErrorCalled)
Barry Wark
fixes and tests for history
r1281 def test_history_returns_expected_block(self):
"""Make sure history browsing doesn't fail"""
blocks = ["a=1","a=2","a=3"]
for b in blocks:
d = self.fb.execute(b)
# d is now the deferred for the last executed block
d.addCallback(self.historyTests, blocks)
def historyTests(self, result, blocks):
"""historyTests"""
assert(len(blocks) >= 3)
assert(self.fb.get_history_previous("") == blocks[-2])
assert(self.fb.get_history_previous("") == blocks[-3])
assert(self.fb.get_history_next() == blocks[-2])
def test_history_returns_none_at_startup(self):
"""test_history_returns_none_at_startup"""
assert(self.fb.get_history_previous("")==None)
assert(self.fb.get_history_next()==None)
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263