##// END OF EJS Templates
Merge pull request #507 from takluyver/prompt-manager...
Merge pull request #507 from takluyver/prompt-manager Prompt manager refactoring: use a new `PromptManager` class responsible for handling everything to do with the prompts. The critical part is its `render` method, which assembles the necessary information, then uses the string formatting introduced in Python 2.6 to fill in the prompt template. I've expanded the definition of 'prompts' to include the auto_rewrite prompt (`"------> "` by default). So there are now four prompts: input, continuation, output, and rewrite. This definition of prompts does not include input/output separators. For now, I've left those as attributes of the main InteractiveShell object.

File last commit:

r2640:93949c91
r5526:272152cc merge
Show More
test_completion_lexer.py
47 lines | 1.4 KiB | text/x-python | PythonLexer
/ IPython / frontend / qt / console / tests / test_completion_lexer.py
# Standard library imports
import unittest
# System library imports
from pygments.lexers import CLexer, CppLexer, PythonLexer
# Local imports
from IPython.frontend.qt.console.completion_lexer import CompletionLexer
class TestCompletionLexer(unittest.TestCase):
def testPython(self):
""" Does the CompletionLexer work for Python?
"""
lexer = CompletionLexer(PythonLexer())
# Test simplest case.
self.assertEquals(lexer.get_context("foo.bar.baz"),
[ "foo", "bar", "baz" ])
# Test trailing period.
self.assertEquals(lexer.get_context("foo.bar."), [ "foo", "bar", "" ])
# Test with prompt present.
self.assertEquals(lexer.get_context(">>> foo.bar.baz"),
[ "foo", "bar", "baz" ])
# Test spacing in name.
self.assertEquals(lexer.get_context("foo.bar. baz"), [ "baz" ])
# Test parenthesis.
self.assertEquals(lexer.get_context("foo("), [])
def testC(self):
""" Does the CompletionLexer work for C/C++?
"""
lexer = CompletionLexer(CLexer())
self.assertEquals(lexer.get_context("foo.bar"), [ "foo", "bar" ])
self.assertEquals(lexer.get_context("foo->bar"), [ "foo", "bar" ])
lexer = CompletionLexer(CppLexer())
self.assertEquals(lexer.get_context("Foo::Bar"), [ "Foo", "Bar" ])
if __name__ == '__main__':
unittest.main()