##// END OF EJS Templates
Backport PR #6061: make CORS configurable...
Backport PR #6061: make CORS configurable allows setting CORS headers. - allow_origin sets Access-Control-Allow-Origin directly - allow_origin_pat allows setting Access-Control-Allow-Origin via regular expression, since the header spec itself doesn’t support nontrivial rules. - allow_credentials sets Access-Control-Allow-Credentials: true ...

File last commit:

r11024:4571a5fb
r17153:8449bcd6
Show More
test_completion_lexer.py
47 lines | 1.4 KiB | text/x-python | PythonLexer
/ IPython / qt / console / tests / test_completion_lexer.py
epatters
Adding unit tests for Qt console frontend.
r2605 # Standard library imports
import unittest
# System library imports
from pygments.lexers import CLexer, CppLexer, PythonLexer
# Local imports
Fernando Perez
Fix all remaining imports that used `IPython.frontend`.
r11024 from IPython.qt.console.completion_lexer import CompletionLexer
epatters
Adding unit tests for Qt console frontend.
r2605
class TestCompletionLexer(unittest.TestCase):
def testPython(self):
""" Does the CompletionLexer work for Python?
"""
lexer = CompletionLexer(PythonLexer())
epatters
* Fixed bug in CompletionLexer where a context would be generated for, e.g, 'foo('....
r2640 # Test simplest case.
Bradley M. Froehle
s/assertEquals/assertEqual/
r7874 self.assertEqual(lexer.get_context("foo.bar.baz"),
epatters
Adding unit tests for Qt console frontend.
r2605 [ "foo", "bar", "baz" ])
epatters
* Fixed bug in CompletionLexer where a context would be generated for, e.g, 'foo('....
r2640
# Test trailing period.
Bradley M. Froehle
s/assertEquals/assertEqual/
r7874 self.assertEqual(lexer.get_context("foo.bar."), [ "foo", "bar", "" ])
epatters
Adding unit tests for Qt console frontend.
r2605
epatters
* Fixed bug in CompletionLexer where a context would be generated for, e.g, 'foo('....
r2640 # Test with prompt present.
Bradley M. Froehle
s/assertEquals/assertEqual/
r7874 self.assertEqual(lexer.get_context(">>> foo.bar.baz"),
epatters
Adding unit tests for Qt console frontend.
r2605 [ "foo", "bar", "baz" ])
epatters
* Fixed bug in CompletionLexer where a context would be generated for, e.g, 'foo('....
r2640
# Test spacing in name.
Bradley M. Froehle
s/assertEquals/assertEqual/
r7874 self.assertEqual(lexer.get_context("foo.bar. baz"), [ "baz" ])
epatters
Adding unit tests for Qt console frontend.
r2605
epatters
* Fixed bug in CompletionLexer where a context would be generated for, e.g, 'foo('....
r2640 # Test parenthesis.
Bradley M. Froehle
s/assertEquals/assertEqual/
r7874 self.assertEqual(lexer.get_context("foo("), [])
epatters
* Fixed bug in CompletionLexer where a context would be generated for, e.g, 'foo('....
r2640
epatters
Adding unit tests for Qt console frontend.
r2605 def testC(self):
""" Does the CompletionLexer work for C/C++?
"""
lexer = CompletionLexer(CLexer())
Bradley M. Froehle
s/assertEquals/assertEqual/
r7874 self.assertEqual(lexer.get_context("foo.bar"), [ "foo", "bar" ])
self.assertEqual(lexer.get_context("foo->bar"), [ "foo", "bar" ])
epatters
Adding unit tests for Qt console frontend.
r2605
lexer = CompletionLexer(CppLexer())
Bradley M. Froehle
s/assertEquals/assertEqual/
r7874 self.assertEqual(lexer.get_context("Foo::Bar"), [ "Foo", "Bar" ])
epatters
Adding unit tests for Qt console frontend.
r2605
if __name__ == '__main__':
unittest.main()