##// END OF EJS Templates
oops
Barry Wark -
Show More
@@ -1,79 +1,77 b''
1 1 # encoding: utf-8
2 2 """This file contains unittests for the ipython1.frontend.cocoa.cocoa_frontend module.
3 3
4 4 Things that should be tested:
5 5
6 6 - IPythonCocoaController instantiates an IEngineInteractive
7 7 - IPythonCocoaController executes code on the engine
8 - IPythonCocoaController returns continuation for incomplete code
9 - IPythonCocoaController returns failure for exceptions raised in executed code
10 8 - IPythonCocoaController mirrors engine's user_ns
11 9 """
12 10 __docformat__ = "restructuredtext en"
13 11
14 12 #-------------------------------------------------------------------------------
15 13 # Copyright (C) 2005 Fernando Perez <fperez@colorado.edu>
16 14 # Brian E Granger <ellisonbg@gmail.com>
17 15 # Benjamin Ragan-Kelley <benjaminrk@gmail.com>
18 16 #
19 17 # Distributed under the terms of the BSD License. The full license is in
20 18 # the file COPYING, distributed as part of this software.
21 19 #-------------------------------------------------------------------------------
22 20
23 21 #-------------------------------------------------------------------------------
24 22 # Imports
25 23 #-------------------------------------------------------------------------------
26 24 from IPython.kernel.core.interpreter import Interpreter
27 25 import IPython.kernel.engineservice as es
28 26 from IPython.testing.util import DeferredTestCase
29 27 from twisted.internet.defer import succeed
30 28 from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController
31 29
32 30 from Foundation import NSMakeRect
33 31 from AppKit import NSTextView, NSScrollView
34 32
35 33 class TestIPythonCocoaControler(DeferredTestCase):
36 34 """Tests for IPythonCocoaController"""
37 35
38 36 def setUp(self):
39 37 self.controller = IPythonCocoaController.alloc().init()
40 38 self.engine = es.EngineService()
41 39 self.engine.startService()
42 40
43 41
44 42 def tearDown(self):
45 43 self.controller = None
46 44 self.engine.stopService()
47 45
48 46 def testControllerExecutesCode(self):
49 47 code ="""5+5"""
50 48 expected = Interpreter().execute(code)
51 49 del expected['number']
52 50 def removeNumberAndID(result):
53 51 del result['number']
54 52 del result['id']
55 53 return result
56 54 self.assertDeferredEquals(self.controller.execute(code).addCallback(removeNumberAndID), expected)
57 55
58 56 def testControllerMirrorsUserNSWithValuesAsStrings(self):
59 57 code = """userns1=1;userns2=2"""
60 58 def testControllerUserNS(result):
61 59 self.assertEquals(self.controller.userNS['userns1'], 1)
62 60 self.assertEquals(self.controller.userNS['userns2'], 2)
63 61
64 62 self.controller.execute(code).addCallback(testControllerUserNS)
65 63
66 64
67 65 def testControllerInstantiatesIEngine(self):
68 66 self.assert_(es.IEngineBase.providedBy(self.controller.engine))
69 67
70 68 def testControllerCompletesToken(self):
71 69 code = """longNameVariable=10"""
72 70 def testCompletes(result):
73 71 self.assert_("longNameVariable" in result)
74 72
75 73 def testCompleteToken(result):
76 74 self.controller.complete("longNa").addCallback(testCompletes)
77 75
78 76 self.controller.execute(code).addCallback(testCompletes)
79 77
General Comments 0
You need to be logged in to leave comments. Login now