<s> """<STR_LIT>""" <EOL> __docformat__ = "<STR_LIT>" <EOL> __test__ = { } <EOL> from twisted . trial import unittest <EOL> from twisted . internet . defer import succeed <EOL> from IPython . kernel . core . interpreter import Interpreter <EOL> import IPython . kernel . engineservice as es <EOL> try : <EOL> from IPython . frontend . cocoa . cocoa_frontend import IPythonCocoaController <EOL> from Foundation import NSMakeRect <EOL> from AppKit import NSTextView , NSScrollView <EOL> except ImportError : <EOL> skip = True <EOL> class TestIPythonCocoaControler ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . controller = IPythonCocoaController . alloc ( ) . init ( ) <EOL> self . engine = es . EngineService ( ) <EOL> self . engine . startService ( ) <EOL> def tearDown ( self ) : <EOL> self . controller = None <EOL> self . engine . stopService ( ) <EOL> def testControllerExecutesCode ( self ) : <EOL> code = """<STR_LIT>""" <EOL> expected = Interpreter ( ) . execute ( code ) <EOL> del expected [ '<STR_LIT>' ] <EOL> def removeNumberAndID ( result ) : <EOL> del result [ '<STR_LIT>' ] <EOL> del result [ '<STR_LIT:id>' ] <EOL> return result <EOL> d = self . controller . execute ( code ) <EOL> d . addCallback ( removeNumberAndID ) <EOL> d . addCallback ( lambda r : self . assertEquals ( r , expected ) ) <EOL> def testControllerMirrorsUserNSWithValuesAsStrings ( self ) : <EOL> code = """<STR_LIT>""" <EOL> def testControllerUserNS ( result ) : <EOL> self . assertEquals ( self . controller . userNS [ '<STR_LIT>' ] , <NUM_LIT:1> ) <EOL> self . assertEquals ( self . controller . userNS [ '<STR_LIT>' ] , <NUM_LIT:2> ) <EOL> self . controller . execute ( code ) . addCallback ( testControllerUserNS ) <EOL> def testControllerInstantiatesIEngine ( self ) : <EOL> self . assert_ ( es . IEngineBase . providedBy ( self . controller . engine ) ) <EOL> def testControllerCompletesToken ( self ) : <EOL> code = """<STR_LIT>""" <EOL> def testCompletes ( result ) : <EOL> self . assert_ ( "<STR_LIT>" in result ) <EOL> def testCompleteToken ( result ) : <EOL> self . controller . complete ( "<STR_LIT>" ) . addCallback ( testCompletes ) <EOL> self . controller . execute ( code ) . addCallback ( testCompletes ) <EOL> def testCurrentIndent ( self ) : <EOL> """<STR_LIT>""" <EOL> self . controller . tabUsesSpaces = True <EOL> self . assert_ ( self . controller . _indent_for_block ( """<STR_LIT>""" ) == None ) <EOL> self . assert_ ( self . controller . _indent_for_block ( "<STR_LIT>" ) == None ) <EOL> block = """<STR_LIT>""" <EOL> self . assert_ ( self . controller . _indent_for_block ( block ) == '<STR_LIT:U+0020>' * self . controller . tabSpaces ) <EOL> block = """<STR_LIT>""" % ( '<STR_LIT:U+0020>' * self . controller . tabSpaces , <EOL> <NUM_LIT:2> * '<STR_LIT:U+0020>' * self . controller . tabSpaces ) <EOL> self . assert_ ( self . controller . _indent_for_block ( block ) == <NUM_LIT:2> * ( '<STR_LIT:U+0020>' * self . controller . tabSpaces ) ) </s>
