test_interpreter.py
57 lines
| 1.9 KiB
| text/x-python
|
PythonLexer
gvaroquaux
|
r1643 | # encoding: utf-8 | ||
"""This file contains unittests for the interpreter.py module.""" | ||||
__docformat__ = "restructuredtext en" | ||||
#----------------------------------------------------------------------------- | ||||
Gael Varoquaux
|
r1898 | # Copyright (C) 2008-2009 The IPython Development Team | ||
gvaroquaux
|
r1643 | # | ||
# Distributed under the terms of the BSD License. The full license is in | ||||
# the file COPYING, distributed as part of this software. | ||||
#----------------------------------------------------------------------------- | ||||
Gael Varoquaux
|
r1898 | |||
gvaroquaux
|
r1643 | #----------------------------------------------------------------------------- | ||
# Imports | ||||
#----------------------------------------------------------------------------- | ||||
from IPython.kernel.core.interpreter import Interpreter | ||||
Gael Varoquaux
|
r1898 | import nose | ||
#----------------------------------------------------------------------------- | ||||
# Tests | ||||
#----------------------------------------------------------------------------- | ||||
gvaroquaux
|
r1643 | |||
def test_unicode(): | ||||
""" Test unicode handling with the interpreter. | ||||
""" | ||||
i = Interpreter() | ||||
i.execute_python(u'print "ù"') | ||||
i.execute_python('print "ù"') | ||||
Gael Varoquaux
|
r1898 | |||
def test_split_commands(): | ||||
""" Test that commands are indeed individually split. | ||||
""" | ||||
i = Interpreter() | ||||
test_atoms = [('(1\n + 1)', ), | ||||
('1', '1', ), | ||||
] | ||||
for atoms in test_atoms: | ||||
atoms = [atom.rstrip() + '\n' for atom in atoms] | ||||
yield nose.tools.assert_equals, i.split_commands(''.join(atoms)), \ | ||||
atoms | ||||
def test_long_lines(): | ||||
""" Test for spurious syntax error created by the interpreter. | ||||
""" | ||||
test_strings = [u'( 1 +\n 1\n )\n\n', | ||||
u'(1 \n + 1\n )\n\n', | ||||
] | ||||
i = Interpreter() | ||||
for s in test_strings: | ||||
yield i.execute, s | ||||