##// END OF EJS Templates
Start integrating new machinery for checking code completeness
Thomas Kluyver -
Show More
@@ -334,15 +334,18 b' class InteractiveShell(SingletonConfigurable):'
334 filename = Unicode("<ipython console>")
334 filename = Unicode("<ipython console>")
335 ipython_dir= Unicode('').tag(config=True) # Set to get_ipython_dir() in __init__
335 ipython_dir= Unicode('').tag(config=True) # Set to get_ipython_dir() in __init__
336
336
337 # Input splitter, to transform input line by line and detect when a block
337 # Used to transform cells before running them, and check whether code is complete
338 # is ready to be executed.
339 input_splitter = Instance('IPython.core.inputsplitter.IPythonInputSplitter',
340 (), {'line_input_checker': True})
341
342 # Used to transform cells before running them.
343 input_transformer_manager = Instance('IPython.core.inputtransformer2.TransformerManager',
338 input_transformer_manager = Instance('IPython.core.inputtransformer2.TransformerManager',
344 ())
339 ())
345
340
341 @property
342 def input_splitter(self):
343 """Make this available for compatibility
344
345 ipykernel currently uses shell.input_splitter.check_complete
346 """
347 return self.input_transformer_manager
348
346 logstart = Bool(False, help=
349 logstart = Bool(False, help=
347 """
350 """
348 Start logging to the default log file in overwrite mode.
351 Start logging to the default log file in overwrite mode.
@@ -179,10 +179,11 b' def test_transform_help():'
179 nt.assert_equal(tf.transform(HELP_MULTILINE[0]), HELP_MULTILINE[2])
179 nt.assert_equal(tf.transform(HELP_MULTILINE[0]), HELP_MULTILINE[2])
180
180
181 def test_check_complete():
181 def test_check_complete():
182 tm = ipt2.TransformerManager()
182 cc = ipt2.TransformerManager().check_complete
183 nt.assert_equal(tm.check_complete("a = 1"), ('complete', None))
183 nt.assert_equal(cc("a = 1"), ('complete', None))
184 nt.assert_equal(tm.check_complete("for a in range(5):"), ('incomplete', 4))
184 nt.assert_equal(cc("for a in range(5):"), ('incomplete', 4))
185 nt.assert_equal(tm.check_complete("raise = 2"), ('invalid', None))
185 nt.assert_equal(cc("raise = 2"), ('invalid', None))
186 nt.assert_equal(tm.check_complete("a = [1,\n2,"), ('incomplete', 0))
186 nt.assert_equal(cc("a = [1,\n2,"), ('incomplete', 0))
187 nt.assert_equal(tm.check_complete("a = '''\n hi"), ('incomplete', 3))
187 nt.assert_equal(cc("a = '''\n hi"), ('incomplete', 3))
188 nt.assert_equal(tm.check_complete("def a():\n x=1\n global x"), ('invalid', None))
188 nt.assert_equal(cc("def a():\n x=1\n global x"), ('invalid', None))
189 nt.assert_equal(cc("a \\ "), ('invalid', None)) # Nothing allowed after backslash
General Comments 0
You need to be logged in to leave comments. Login now