Show More
@@ -0,0 +1,37 b'' | |||||
|
1 | """Tests for the key interactiveshell module. | |||
|
2 | ||||
|
3 | Historically the main classes in interactiveshell have been under-tested. This | |||
|
4 | module should grow as many single-method tests as possible to trap many of the | |||
|
5 | recurring bugs we seem to encounter with high-level interaction. | |||
|
6 | ||||
|
7 | Authors | |||
|
8 | ------- | |||
|
9 | * Fernando Perez | |||
|
10 | """ | |||
|
11 | #----------------------------------------------------------------------------- | |||
|
12 | # Copyright (C) 2011 The IPython Development Team | |||
|
13 | # | |||
|
14 | # Distributed under the terms of the BSD License. The full license is in | |||
|
15 | # the file COPYING, distributed as part of this software. | |||
|
16 | #----------------------------------------------------------------------------- | |||
|
17 | ||||
|
18 | #----------------------------------------------------------------------------- | |||
|
19 | # Imports | |||
|
20 | #----------------------------------------------------------------------------- | |||
|
21 | # stdlib | |||
|
22 | import unittest | |||
|
23 | ||||
|
24 | #----------------------------------------------------------------------------- | |||
|
25 | # Tests | |||
|
26 | #----------------------------------------------------------------------------- | |||
|
27 | ||||
|
28 | class InteractiveShellTestCase(unittest.TestCase): | |||
|
29 | def test_naked_string_cells(self): | |||
|
30 | """Test that cells with only naked strings are fully executed""" | |||
|
31 | ip = get_ipython() | |||
|
32 | # First, single-line inputs | |||
|
33 | ip.run_cell('"a"\n') | |||
|
34 | self.assertEquals(ip.user_ns['_'], 'a') | |||
|
35 | # And also multi-line cells | |||
|
36 | ip.run_cell('"""a\nb"""\n') | |||
|
37 | self.assertEquals(ip.user_ns['_'], 'a\nb') |
@@ -2174,8 +2174,11 b' class InteractiveShell(Configurable, Magic):' | |||||
2174 | if len(block.splitlines()) <= 1: |
|
2174 | if len(block.splitlines()) <= 1: | |
2175 | out = self.run_single_line(block) |
|
2175 | out = self.run_single_line(block) | |
2176 | else: |
|
2176 | else: | |
2177 | out = self.run_code(block) |
|
2177 | # Call run_source, which correctly compiles the input cell. | |
2178 | #out = self.run_source(block) |
|
2178 | # run_code must only be called when we know we have a code object, | |
|
2179 | # as it does a naked exec and the compilation mode may not be what | |||
|
2180 | # we wanted. | |||
|
2181 | out = self.run_source(block) | |||
2179 | return out |
|
2182 | return out | |
2180 |
|
2183 | |||
2181 | def run_single_line(self, line): |
|
2184 | def run_single_line(self, line): |
General Comments 0
You need to be logged in to leave comments.
Login now