##// END OF EJS Templates
regenerate css
regenerate css

File last commit:

r5390:c82649ea
r9281:503c803f
Show More
test_cocoa_frontend.py
100 lines | 3.7 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
Bernardo B. Marques
remove all trailling spaces
r4872 """This file contains unittests for the
Barry Wark
pep8 compliance, first pass
r1291 IPython.frontend.cocoa.cocoa_frontend module.
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 """
__docformat__ = "restructuredtext en"
Bernardo B. Marques
remove all trailling spaces
r4872
Barry Wark
pep8 compliance, first pass
r1291 #---------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2005-2011 The IPython Development Team
Bernardo B. Marques
remove all trailling spaces
r4872 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
Barry Wark
pep8 compliance, first pass
r1291 #---------------------------------------------------------------------------
Bernardo B. Marques
remove all trailling spaces
r4872
Barry Wark
pep8 compliance, first pass
r1291 #---------------------------------------------------------------------------
Bernardo B. Marques
remove all trailling spaces
r4872 # Imports
Barry Wark
pep8 compliance, first pass
r1291 #---------------------------------------------------------------------------
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing misc testing related things.
r1960 # Tell nose to skip this module
__test__ = {}
from twisted.trial import unittest
from twisted.internet.defer import succeed
from IPython.kernel.core.interpreter import Interpreter
import IPython.kernel.engineservice as es
Brian Granger
Addressing various review comments.
r1958
Brian Granger
Fixing small bugs for the release....
r1551 try:
Brian Granger
Fixing misc testing related things.
r1960 from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 from Foundation import NSMakeRect
Brian Granger
Addressing various review comments.
r1958 from AppKit import NSTextView, NSScrollView
Brian Granger
Fixing small bugs for the release....
r1551 except ImportError:
Brian Granger
Fixing misc testing related things.
r1960 # This tells twisted.trial to skip this module if PyObjC is not found
skip = True
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555
Brian Granger
Fixing misc testing related things.
r1960 #---------------------------------------------------------------------------
# Tests
#---------------------------------------------------------------------------
class TestIPythonCocoaControler(unittest.TestCase):
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 """Tests for IPythonCocoaController"""
Brian Granger
Fixing misc testing related things.
r1960
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 def setUp(self):
self.controller = IPythonCocoaController.alloc().init()
self.engine = es.EngineService()
self.engine.startService()
Brian Granger
Fixing misc testing related things.
r1960
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 def tearDown(self):
self.controller = None
self.engine.stopService()
Brian Granger
Fixing misc testing related things.
r1960
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 def testControllerExecutesCode(self):
code ="""5+5"""
expected = Interpreter().execute(code)
del expected['number']
def removeNumberAndID(result):
del result['number']
del result['id']
return result
Brian Granger
Fixing misc testing related things.
r1960 d = self.controller.execute(code)
d.addCallback(removeNumberAndID)
d.addCallback(lambda r: self.assertEquals(r, expected))
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 def testControllerMirrorsUserNSWithValuesAsStrings(self):
code = """userns1=1;userns2=2"""
def testControllerUserNS(result):
self.assertEquals(self.controller.userNS['userns1'], 1)
self.assertEquals(self.controller.userNS['userns2'], 2)
self.controller.execute(code).addCallback(testControllerUserNS)
Brian Granger
Fixing misc testing related things.
r1960
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 def testControllerInstantiatesIEngine(self):
self.assert_(es.IEngineBase.providedBy(self.controller.engine))
Brian Granger
Fixing misc testing related things.
r1960
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 def testControllerCompletesToken(self):
code = """longNameVariable=10"""
def testCompletes(result):
self.assert_("longNameVariable" in result)
Brian Granger
Fixing misc testing related things.
r1960
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 def testCompleteToken(result):
self.controller.complete("longNa").addCallback(testCompletes)
Brian Granger
Fixing misc testing related things.
r1960
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 self.controller.execute(code).addCallback(testCompletes)
Brian Granger
Fixing misc testing related things.
r1960
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 def testCurrentIndent(self):
"""test that current_indent_string returns current indent or None.
Uses _indent_for_block for direct unit testing.
"""
Bernardo B. Marques
remove all trailling spaces
r4872
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 self.controller.tabUsesSpaces = True
self.assert_(self.controller._indent_for_block("""a=3""") == None)
self.assert_(self.controller._indent_for_block("") == None)
block = """def test():\n a=3"""
self.assert_(self.controller._indent_for_block(block) == \
' ' * self.controller.tabSpaces)
Bernardo B. Marques
remove all trailling spaces
r4872
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 block = """if(True):\n%sif(False):\n%spass""" % \
(' '*self.controller.tabSpaces,
2*' '*self.controller.tabSpaces)
self.assert_(self.controller._indent_for_block(block) == \
2*(' '*self.controller.tabSpaces))
Brian Granger
Fixing misc testing related things.
r1960