1010from IPython .testing import tools as tt
1111from IPython .utils .capture import capture_output
1212
13- from IPython .terminal .ptutils import _elide
13+ from IPython .terminal .ptutils import _elide , _adjust_completion_text_based_on_context
1414import nose .tools as nt
1515
1616class TestElide (unittest .TestCase ):
@@ -20,6 +20,19 @@ def test_elide(self):
2020 _elide ('concatenate((a1, a2, ..), . axis' ) # do not raise
2121 nt .assert_equal (_elide ('aaaa.bbbb.ccccc.dddddd.eeeee.fffff.gggggg.hhhhhh' ), 'aaaa.b…g.hhhhhh' )
2222
23+
24+ class TestContextAwareCompletion (unittest .TestCase ):
25+
26+ def test_adjust_completion_text_based_on_context (self ):
27+ # Adjusted case
28+ nt .assert_equal (_adjust_completion_text_based_on_context ('arg1=' , 'func1(a=)' , 7 ), 'arg1' )
29+
30+ # Untouched cases
31+ nt .assert_equal (_adjust_completion_text_based_on_context ('arg1=' , 'func1(a)' , 7 ), 'arg1=' )
32+ nt .assert_equal (_adjust_completion_text_based_on_context ('arg1=' , 'func1(a' , 7 ), 'arg1=' )
33+ nt .assert_equal (_adjust_completion_text_based_on_context ('%magic' , 'func1(a=)' , 7 ), '%magic' )
34+ nt .assert_equal (_adjust_completion_text_based_on_context ('func2' , 'func1(a=)' , 7 ), 'func2' )
35+
2336# Decorator for interaction loop tests -----------------------------------------
2437
2538class mock_input_helper (object ):
0 commit comments