##// END OF EJS Templates
Fix test for issue #114, in this case the test had a small error....
Fernando Perez -
Show More
@@ -1,59 +1,68 b''
1 1 """Tests for input manipulation machinery."""
2 2
3 3 #-----------------------------------------------------------------------------
4 4 # Imports
5 5 #-----------------------------------------------------------------------------
6 6 import nose.tools as nt
7 7
8 8 from IPython.testing import tools as tt, decorators as dec
9 9 from IPython.testing.globalipapp import get_ipython
10 10
11 11 #-----------------------------------------------------------------------------
12 12 # Tests
13 13 #-----------------------------------------------------------------------------
14 14 ip = get_ipython()
15 15
16 16 @dec.parametric
17 17 def test_prefilter():
18 18 """Test user input conversions"""
19 19
20 20 # pairs of (raw, expected correct) input
21 21 pairs = [ ('2+2','2+2'),
22 22 ('>>> 2+2','2+2'),
23 23 ('>>> # This is a comment\n'
24 24 '... 2+2',
25 25 '# This is a comment\n'
26 26 '2+2'),
27 27 # Some IPython input
28 28 ('In [1]: 1', '1'),
29 29 ('In [2]: for i in range(5):\n'
30 30 ' ...: print i,',
31 31 'for i in range(5):\n'
32 32 ' print i,'),
33 33 ]
34 34
35 35 for raw, correct in pairs:
36 36 yield nt.assert_equals(ip.prefilter(raw), correct)
37 37
38 38 @dec.parametric
39 39 def test_autocall_binops():
40 40 """See https://bugs.launchpad.net/ipython/+bug/315706"""
41 41 ip.magic('autocall 2')
42 42 f = lambda x: x
43 43 ip.user_ns['f'] = f
44 44 try:
45 45 yield nt.assert_equals(ip.prefilter('f 1'),'f(1)')
46 46 for t in ['f +1', 'f -1']:
47 47 yield nt.assert_equals(ip.prefilter(t), t)
48 48 finally:
49 49 ip.magic('autocall 0')
50 50 del ip.user_ns['f']
51 51
52 52 @dec.parametric
53 53 def test_issue114():
54 54 """Check that multiline string literals don't expand as magic
55 55 see http://github.com/ipython/ipython/issues/#issue/114"""
56
56 57 template = '"""\n%s\n"""'
57 for mgk in ip.lsmagic():
58 raw = template % mgk
59 yield nt.assert_equals(ip.prefilter(raw), raw)
58 # Store the current value of multi_line_specials and turn it off before
59 # running test, since it could be true (case in which the test doesn't make
60 # sense, as multiline string literals *will* expand as magic in that case).
61 msp = ip.prefilter_manager.multi_line_specials
62 ip.prefilter_manager.multi_line_specials = False
63 try:
64 for mgk in ip.lsmagic():
65 raw = template % mgk
66 yield nt.assert_equals(ip.prefilter(raw), raw)
67 finally:
68 ip.prefilter_manager.multi_line_specials = msp
General Comments 0
You need to be logged in to leave comments. Login now