From 945e03e6ea012abfc9108beea98cc8a1493e4b5a 2008-08-11 22:40:27 From: gvaroquaux Date: 2008-08-11 22:40:27 Subject: [PATCH] Test completion. --- diff --git a/IPython/frontend/linefrontendbase.py b/IPython/frontend/linefrontendbase.py index e00cc06..9a35925 100644 --- a/IPython/frontend/linefrontendbase.py +++ b/IPython/frontend/linefrontendbase.py @@ -204,6 +204,12 @@ class LineFrontEndBase(FrontEndBase): print >>sys.__stdout__, completions + def get_line_width(self): + """ Return the width of the line in characters. + """ + return 80 + + def write_completion(self, possibilities): """ Write the list of possible completions. """ @@ -212,8 +218,8 @@ class LineFrontEndBase(FrontEndBase): self.write('\n') max_len = len(max(possibilities, key=len)) + 1 - #now we check how much symbol we can put on a line... - chars_per_line =self.get_line_width() + # Now we check how much symbol we can put on a line... + chars_per_line = self.get_line_width() symbols_per_line = max(1, chars_per_line/max_len) pos = 1 @@ -231,7 +237,6 @@ class LineFrontEndBase(FrontEndBase): self.input_buffer = current_buffer - def new_prompt(self, prompt): """ Prints a prompt and starts a new editing buffer. diff --git a/IPython/frontend/tests/test_prefilterfrontend.py b/IPython/frontend/tests/test_prefilterfrontend.py index 8e36bb9..fa92aea 100644 --- a/IPython/frontend/tests/test_prefilterfrontend.py +++ b/IPython/frontend/tests/test_prefilterfrontend.py @@ -115,6 +115,9 @@ def test_completion(): f.input_buffer = 'zzzb = 2' f._on_enter() f.input_buffer = 'zz' + f.complete_current_input() + assert f.out.getvalue() == '\nzzza zzzb ' + assert f.input_buffer == 'zzz' if __name__ == '__main__': @@ -123,3 +126,4 @@ if __name__ == '__main__': test_execution() test_multiline() test_capture() + test_completion()