Show More
@@ -24,23 +24,19 b' __docformat__ = "restructuredtext en"' | |||
|
24 | 24 | # Imports |
|
25 | 25 | #------------------------------------------------------------------------------- |
|
26 | 26 | from IPython.kernel.core.interpreter import Interpreter |
|
27 | from IPython.testutils.parametric import Parametric, parametric | |
|
28 | from IPython.kernel.core.interpreter import COMPILER_ERROR, INCOMPLETE_INPUT,\ | |
|
29 | COMPLETE_INPUT | |
|
30 | 27 | import IPython.kernel.engineservice as es |
|
31 |
from IPython.test |
|
|
28 | from IPython.testing.util import DeferredTestCase | |
|
32 | 29 | from twisted.internet.defer import succeed |
|
33 |
from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController |
|
|
34 | IPythonCLITextViewDelegate,\ | |
|
35 | CompilerError | |
|
30 | from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController | |
|
36 | 31 | |
|
32 | from Foundation import NSMakeRect | |
|
33 | from AppKit import NSTextView, NSScrollView | |
|
37 | 34 | |
|
38 | 35 | class TestIPythonCocoaControler(DeferredTestCase): |
|
39 | 36 | """Tests for IPythonCocoaController""" |
|
40 | 37 | |
|
41 | 38 | def setUp(self): |
|
42 | 39 | self.controller = IPythonCocoaController.alloc().init() |
|
43 | self.controller.awakeFromNib() | |
|
44 | 40 | self.engine = es.EngineService() |
|
45 | 41 | self.engine.startService() |
|
46 | 42 | |
@@ -57,31 +53,19 b' class TestIPythonCocoaControler(DeferredTestCase):' | |||
|
57 | 53 | del result['number'] |
|
58 | 54 | del result['id'] |
|
59 | 55 | return result |
|
60 |
self.assertDeferredEquals(self.controller.execute |
|
|
61 | ||
|
62 | def testControllerReturnsNoneForIncompleteCode(self): | |
|
63 | code = """def test(a):""" | |
|
64 | expected = None | |
|
65 | self.assertDeferredEquals(self.controller.executeRequest([code]), expected) | |
|
66 | ||
|
67 | ||
|
68 | def testControllerRaisesCompilerErrorForIllegalCode(self): | |
|
69 | """testControllerRaisesCompilerErrorForIllegalCode""" | |
|
70 | ||
|
71 | code = """def test() pass""" | |
|
72 | self.assertDeferredRaises(self.controller.executeRequest([code]), CompilerError) | |
|
56 | self.assertDeferredEquals(self.controller.execute(code).addCallback(removeNumberAndID), expected) | |
|
73 | 57 | |
|
74 | 58 | def testControllerMirrorsUserNSWithValuesAsStrings(self): |
|
75 | 59 | code = """userns1=1;userns2=2""" |
|
76 | 60 | def testControllerUserNS(result): |
|
77 |
self.assertEquals(self.controller.userNS['userns1'], |
|
|
78 |
self.assertEquals(self.controller.userNS['userns2'], |
|
|
61 | self.assertEquals(self.controller.userNS['userns1'], 1) | |
|
62 | self.assertEquals(self.controller.userNS['userns2'], 2) | |
|
79 | 63 | |
|
80 |
self.controller.execute |
|
|
64 | self.controller.execute(code).addCallback(testControllerUserNS) | |
|
81 | 65 | |
|
82 | 66 | |
|
83 | 67 | def testControllerInstantiatesIEngine(self): |
|
84 | self.assert_(es.IEngine.providedBy(self.controller.engine)) | |
|
68 | self.assert_(es.IEngineBase.providedBy(self.controller.engine)) | |
|
85 | 69 | |
|
86 | 70 | def testControllerCompletesToken(self): |
|
87 | 71 | code = """longNameVariable=10""" |
@@ -91,7 +75,5 b' class TestIPythonCocoaControler(DeferredTestCase):' | |||
|
91 | 75 | def testCompleteToken(result): |
|
92 | 76 | self.controller.complete("longNa").addCallback(testCompletes) |
|
93 | 77 | |
|
94 |
self.controller.execute |
|
|
78 | self.controller.execute(code).addCallback(testCompletes) | |
|
95 | 79 | |
|
96 | ||
|
97 | Parametric(TestIPythonCocoaControler) No newline at end of file |
@@ -847,6 +847,13 b' class Command(object):' | |||
|
847 | 847 | self.deferred.errback(reason) |
|
848 | 848 | |
|
849 | 849 | class ThreadedEngineService(EngineService): |
|
850 | """An EngineService subclass that defers execute commands to a separate thread. | |
|
851 | ||
|
852 | ThreadedEngineService uses twisted.internet.threads.deferToThread to defer execute | |
|
853 | requests to a separate thread. GUI frontends may want to use ThreadedEngineService as | |
|
854 | the engine in an IPython.frontend.frontendbase.FrontEndBase subclass to prevent | |
|
855 | block execution from blocking the GUI thread. | |
|
856 | """ | |
|
850 | 857 | |
|
851 | 858 | zi.implements(IEngineBase) |
|
852 | 859 |
General Comments 0
You need to be logged in to leave comments.
Login now