##// END OF EJS Templates
Adding tests and limiting CM mode to python 3.
Brian E. Granger -
Show More
@@ -126,6 +126,27 b' def test_unicode_completions():'
126 nt.assert_true(isinstance(text, string_types))
126 nt.assert_true(isinstance(text, string_types))
127 nt.assert_true(isinstance(matches, list))
127 nt.assert_true(isinstance(matches, list))
128
128
129 @dec.onlyif(sys.version_info[0] >= 3, 'This test only applies in Py>=3')
130 def test_latex_completions():
131 from IPython.core.latex_symbols import latex_symbols
132 import random
133 ip = get_ipython()
134 # Test some random unicode symbols
135 keys = random.sample(latex_symbols.keys(), 10)
136 for k in keys:
137 text, matches = ip.complete(k)
138 nt.assert_equal(len(matches),1)
139 nt.assert_equal(text, k)
140 mt.assert_equal(matches[0], latex_symbols[k])
141 # Test a more complex line
142 text, matches = ip.complete(u'print(\\alpha')
143 nt.assert_equals(text, u'\\alpha')
144 nt.assert_equals(matches[0], latex_symbols['\\alpha'])
145 # Test multiple matching latex symbols
146 text, matches = ip.complete(u'\\al')
147 nt.assert_in('\\alpha', matches)
148 nt.assert_in('\\aleph', matches)
149
129
150
130 class CompletionSplitterTestCase(unittest.TestCase):
151 class CompletionSplitterTestCase(unittest.TestCase):
131 def setUp(self):
152 def setUp(self):
@@ -15,7 +15,12 b" CodeMirror.requireMode('python',function(){"
15 }
15 }
16 pythonConf.name = 'python';
16 pythonConf.name = 'python';
17 pythonConf.singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\\?]");
17 pythonConf.singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\\?]");
18 pythonConf.identifiers = new RegExp("^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*");
18 if (pythonConf.version === 3) {
19 console.log('setting up for python 3');
20 pythonConf.identifiers = new RegExp("^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*");
21 } else if (pythonConf.version === 2) {
22 pythonConf.identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
23 }
19 return CodeMirror.getMode(conf, pythonConf);
24 return CodeMirror.getMode(conf, pythonConf);
20 }, 'python');
25 }, 'python');
21
26
General Comments 0
You need to be logged in to leave comments. Login now