MCPcopy Create free account
hub / github.com/ipython/ipython / test_check_complete

Function test_check_complete

IPython/core/tests/test_inputtransformer2.py:256–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

254 nt.assert_equal(_find_assign_op([Tk(s) for s in ('','(', 'a','=','b', ')', '=' ,'5')]), 6)
255
256def test_check_complete():
257 cc = ipt2.TransformerManager().check_complete
258 nt.assert_equal(cc("a = 1"), ('complete', None))
259 nt.assert_equal(cc("for a in range(5):"), ('incomplete', 4))
260 nt.assert_equal(cc("for a in range(5):\n if a > 0:"), ('incomplete', 8))
261 nt.assert_equal(cc("raise = 2"), ('invalid', None))
262 nt.assert_equal(cc("a = [1,\n2,"), ('incomplete', 0))
263 nt.assert_equal(cc(")"), ('incomplete', 0))
264 nt.assert_equal(cc("\\\r\n"), ('incomplete', 0))
265 nt.assert_equal(cc("a = '''\n hi"), ('incomplete', 3))
266 nt.assert_equal(cc("def a():\n x=1\n global x"), ('invalid', None))
267 nt.assert_equal(cc("a \\ "), ('invalid', None)) # Nothing allowed after backslash
268 nt.assert_equal(cc("1\\\n+2"), ('complete', None))
269 nt.assert_equal(cc("exit"), ('complete', None))
270
271 example = dedent("""
272 if True:
273 a=1""" )
274
275 nt.assert_equal(cc(example), ('incomplete', 4))
276 nt.assert_equal(cc(example+'\n'), ('complete', None))
277 nt.assert_equal(cc(example+'\n '), ('complete', None))
278
279 # no need to loop on all the letters/numbers.
280 short = '12abAB'+string.printable[62:]
281 for c in short:
282 # test does not raise:
283 cc(c)
284 for k in short:
285 cc(c+k)
286
287 nt.assert_equal(cc("def f():\n x=0\n \\\n "), ('incomplete', 2))
288
289def test_check_complete_II():
290 """

Callers

nothing calls this directly

Calls 1

dedentFunction · 0.85

Tested by

no test coverage detected