##// END OF EJS Templates
fixed ipython1->IPython in cocoa/tests/test_cocoa_frontend.py
Barry Wark -
Show More
@@ -1,97 +1,97 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 8 - IPythonCocoaController returns continuation for incomplete code
9 9 - IPythonCocoaController returns failure for exceptions raised in executed code
10 10 - IPythonCocoaController mirrors engine's user_ns
11 11 """
12 12 __docformat__ = "restructuredtext en"
13 13
14 14 #-------------------------------------------------------------------------------
15 15 # Copyright (C) 2005 Fernando Perez <fperez@colorado.edu>
16 16 # Brian E Granger <ellisonbg@gmail.com>
17 17 # Benjamin Ragan-Kelley <benjaminrk@gmail.com>
18 18 #
19 19 # Distributed under the terms of the BSD License. The full license is in
20 20 # the file COPYING, distributed as part of this software.
21 21 #-------------------------------------------------------------------------------
22 22
23 23 #-------------------------------------------------------------------------------
24 24 # Imports
25 25 #-------------------------------------------------------------------------------
26 from ipython1.core.interpreter import Interpreter
27 from ipython1.testutils.parametric import Parametric, parametric
28 from ipython1.core.interpreter import COMPILER_ERROR, INCOMPLETE_INPUT,\
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 29 COMPLETE_INPUT
30 import ipython1.kernel.engineservice as es
31 from ipython1.testutils.util import DeferredTestCase
30 import IPython.kernel.engineservice as es
31 from IPython.testutils.util import DeferredTestCase
32 32 from twisted.internet.defer import succeed
33 from ipython1.frontend.cocoa.cocoa_frontend import IPythonCocoaController,\
33 from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController,\
34 34 IPythonCLITextViewDelegate,\
35 35 CompilerError
36 36
37 37
38 38 class TestIPythonCocoaControler(DeferredTestCase):
39 39 """Tests for IPythonCocoaController"""
40 40
41 41 def setUp(self):
42 42 self.controller = IPythonCocoaController.alloc().init()
43 43 self.controller.awakeFromNib()
44 44 self.engine = es.EngineService()
45 45 self.engine.startService()
46 46
47 47
48 48 def tearDown(self):
49 49 self.controller = None
50 50 self.engine.stopService()
51 51
52 52 def testControllerExecutesCode(self):
53 53 code ="""5+5"""
54 54 expected = Interpreter().execute(code)
55 55 del expected['number']
56 56 def removeNumberAndID(result):
57 57 del result['number']
58 58 del result['id']
59 59 return result
60 60 self.assertDeferredEquals(self.controller.executeRequest([code]).addCallback(removeNumberAndID), expected)
61 61
62 62 def testControllerReturnsNoneForIncompleteCode(self):
63 63 code = """def test(a):"""
64 64 expected = None
65 65 self.assertDeferredEquals(self.controller.executeRequest([code]), expected)
66 66
67 67
68 68 def testControllerRaisesCompilerErrorForIllegalCode(self):
69 69 """testControllerRaisesCompilerErrorForIllegalCode"""
70 70
71 71 code = """def test() pass"""
72 72 self.assertDeferredRaises(self.controller.executeRequest([code]), CompilerError)
73 73
74 74 def testControllerMirrorsUserNSWithValuesAsStrings(self):
75 75 code = """userns1=1;userns2=2"""
76 76 def testControllerUserNS(result):
77 77 self.assertEquals(self.controller.userNS['userns1'], str(1))
78 78 self.assertEquals(self.controller.userNS['userns2'], str(2))
79 79
80 80 self.controller.executeRequest([code]).addCallback(testControllerUserNS)
81 81
82 82
83 83 def testControllerInstantiatesIEngine(self):
84 84 self.assert_(es.IEngine.providedBy(self.controller.engine))
85 85
86 86 def testControllerCompletesToken(self):
87 87 code = """longNameVariable=10"""
88 88 def testCompletes(result):
89 89 self.assert_("longNameVariable" in result)
90 90
91 91 def testCompleteToken(result):
92 92 self.controller.complete("longNa").addCallback(testCompletes)
93 93
94 94 self.controller.executeRequest([code]).addCallback(testCompletes)
95 95
96 96
97 97 Parametric(TestIPythonCocoaControler) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now