~ellisonbg/ipython/bugfixes0411409

« back to all changes in this revision

Viewing changes to test/test_completer.py

  • Committer: ville
  • Date: 2008-02-16 09:50:47 UTC
  • mto: (0.12.1 ipython_main)
  • mto: This revision was merged to the branch mainline in revision 990.
  • Revision ID: ville@ville-pc-20080216095047-500x6dluki1iz40o
initialization (no svn history)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
comp
 
3
"""
 
4
 
 
5
# The prefilter always ends in a call to some self.handle_X method.  We swap
 
6
# all of those out so that we can capture which one was called.
 
7
 
 
8
import sys
 
9
sys.path.append('..')
 
10
import IPython
 
11
import IPython.ipapi
 
12
    
 
13
IPython.Shell.start()
 
14
 
 
15
ip = IPython.ipapi.get()
 
16
 
 
17
completer = ip.IP.Completer
 
18
 
 
19
print completer
 
20
 
 
21
def do_test(text, line):
 
22
    def get_endix():
 
23
        idx = len(line)
 
24
        print "Call endidx =>",idx        
 
25
        return idx
 
26
    def get_line_buffer():
 
27
        print "Lbuf =>",line
 
28
        return line
 
29
    completer.get_line_buffer = get_line_buffer
 
30
    completer.get_endidx = get_endix
 
31
    l = completer.all_completions(text)
 
32
    return l
 
33
    
 
34
l = do_test ('p', 'print p')
 
35
assert 'pow' in l
 
36
l = do_test ('p', 'import p')
 
37
assert 'pprint' in l
 
 
b'\\ No newline at end of file'