@@ -905,6 +905,40 @@ def _bar_cellm(line, cell):
905905 self .assertNotIn ("%_bar_cellm" , matches )
906906 self .assertIn ("%%_bar_cellm" , matches )
907907
908+ def test_line_magics_with_code_argument (self ):
909+ ip = get_ipython ()
910+ c = ip .Completer
911+ c .use_jedi = False
912+
913+ # attribute completion
914+ text , matches = c .complete ("%timeit -n 2 -r 1 float.as_integer" )
915+ self .assertEqual (matches , [".as_integer_ratio" ])
916+
917+ text , matches = c .complete ("%debug --breakpoint test float.as_integer" )
918+ self .assertEqual (matches , [".as_integer_ratio" ])
919+
920+ text , matches = c .complete ("%time --no-raise-error float.as_integer" )
921+ self .assertEqual (matches , [".as_integer_ratio" ])
922+
923+ text , matches = c .complete ("%prun -l 0.5 -r float.as_integer" )
924+ self .assertEqual (matches , [".as_integer_ratio" ])
925+
926+ # implicit magics
927+ text , matches = c .complete ("timeit -n 2 -r 1 float.as_integer" )
928+ self .assertEqual (matches , [".as_integer_ratio" ])
929+
930+ # built-ins completion
931+ text , matches = c .complete ("%timeit -n 2 -r 1 flo" )
932+ self .assertEqual (matches , ["float" ])
933+
934+ # dict completion
935+ text , matches = c .complete ("%timeit -n 2 -r 1 {'my_key': 1}['my" )
936+ self .assertEqual (matches , ["my_key" ])
937+
938+ # invalid arguments - should not throw
939+ text , matches = c .complete ("%timeit -n 2 -r 1 -invalid float.as_integer" )
940+ self .assertEqual (matches , [])
941+
908942 def test_magic_completion_order (self ):
909943 ip = get_ipython ()
910944 c = ip .Completer
0 commit comments