##// END OF EJS Templates
Fixing small bugs for the release....
Fixing small bugs for the release. * Fixing imports in tests when deps are not present. * Removed shell.py and test_shell.py as they are old. * Adding notes about installation and testing.

File last commit:

r1551:d8f2aac4
r1551:d8f2aac4
Show More
test_cocoa_frontend.py
92 lines | 3.9 KiB | text/x-python | PythonLexer
/ IPython / frontend / cocoa / tests / test_cocoa_frontend.py
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 # encoding: utf-8
Barry Wark
pep8 compliance, first pass
r1291 """This file contains unittests for the
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"
Barry Wark
pep8 compliance, first pass
r1291
#---------------------------------------------------------------------------
# Copyright (C) 2005 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
#---------------------------------------------------------------------------
from IPython.kernel.core.interpreter import Interpreter
Barry Wark
fixed ipython1->IPython in cocoa/tests/test_cocoa_frontend.py
r1264 import IPython.kernel.engineservice as es
Barry Wark
cocoa frontend tests
r1275 from IPython.testing.util import DeferredTestCase
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263 from twisted.internet.defer import succeed
Brian Granger
Fixing small bugs for the release....
r1551 try:
from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController
from Foundation import NSMakeRect
from AppKit import NSTextView, NSScrollView
except ImportError:
class TestIPythonCocoaControler(DeferredTestCase):
"""Tests for IPythonCocoaController"""
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing small bugs for the release....
r1551 def setUp(self):
self.controller = IPythonCocoaController.alloc().init()
self.engine = es.EngineService()
self.engine.startService()
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing small bugs for the release....
r1551 def tearDown(self):
self.controller = None
self.engine.stopService()
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing small bugs for the release....
r1551 def testControllerExecutesCode(self):
code ="""5+5"""
expected = Interpreter().execute(code)
del expected['number']
def removeNumberAndID(result):
del result['number']
del result['id']
return result
self.assertDeferredEquals(
self.controller.execute(code).addCallback(removeNumberAndID),
expected)
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing small bugs for the release....
r1551 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)
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing small bugs for the release....
r1551 self.controller.execute(code).addCallback(testControllerUserNS)
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing small bugs for the release....
r1551 def testControllerInstantiatesIEngine(self):
self.assert_(es.IEngineBase.providedBy(self.controller.engine))
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing small bugs for the release....
r1551 def testControllerCompletesToken(self):
code = """longNameVariable=10"""
def testCompletes(result):
self.assert_("longNameVariable" in result)
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing small bugs for the release....
r1551 def testCompleteToken(result):
self.controller.complete("longNa").addCallback(testCompletes)
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Brian Granger
Fixing small bugs for the release....
r1551 self.controller.execute(code).addCallback(testCompletes)
Barry Wark
moved frontend from ipython1-dev. Got engineservice.ThreadedEngineService running, but does nto correctly propagate errors during execute()
r1263
Barry Wark
fix for cocoa frontend current_indent_string; refactor to make testing easier and added a test for _indent_for_block
r1300
Brian Granger
Fixing small bugs for the release....
r1551 def testCurrentIndent(self):
"""test that current_indent_string returns current indent or None.
Uses _indent_for_block for direct unit testing.
"""
Barry Wark
fix for cocoa frontend current_indent_string; refactor to make testing easier and added a test for _indent_for_block
r1300
Brian Granger
Fixing small bugs for the release....
r1551 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)
Barry Wark
fix for cocoa frontend current_indent_string; refactor to make testing easier and added a test for _indent_for_block
r1300
Brian Granger
Fixing small bugs for the release....
r1551 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))
Barry Wark
fix for cocoa frontend current_indent_string; refactor to make testing easier and added a test for _indent_for_block
r1300