Show More
@@ -1,51 +1,59 b'' | |||||
1 | """Tests for input manipulation machinery.""" |
|
1 | """Tests for input manipulation machinery.""" | |
2 |
|
2 | |||
3 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
4 | # Imports |
|
4 | # Imports | |
5 | #----------------------------------------------------------------------------- |
|
5 | #----------------------------------------------------------------------------- | |
6 | import nose.tools as nt |
|
6 | import nose.tools as nt | |
7 |
|
7 | |||
8 | from IPython.testing import tools as tt, decorators as dec |
|
8 | from IPython.testing import tools as tt, decorators as dec | |
|
9 | from IPython.testing.globalipapp import get_ipython | |||
9 |
|
10 | |||
10 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- | |
11 | # Tests |
|
12 | # Tests | |
12 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
13 | ip = get_ipython() |
|
14 | ip = get_ipython() | |
14 |
|
15 | |||
15 | @dec.parametric |
|
16 | @dec.parametric | |
16 | def test_prefilter(): |
|
17 | def test_prefilter(): | |
17 | """Test user input conversions""" |
|
18 | """Test user input conversions""" | |
18 |
|
19 | |||
19 | # pairs of (raw, expected correct) input |
|
20 | # pairs of (raw, expected correct) input | |
20 | pairs = [ ('2+2','2+2'), |
|
21 | pairs = [ ('2+2','2+2'), | |
21 | ('>>> 2+2','2+2'), |
|
22 | ('>>> 2+2','2+2'), | |
22 | ('>>> # This is a comment\n' |
|
23 | ('>>> # This is a comment\n' | |
23 | '... 2+2', |
|
24 | '... 2+2', | |
24 | '# This is a comment\n' |
|
25 | '# This is a comment\n' | |
25 | '2+2'), |
|
26 | '2+2'), | |
26 | # Some IPython input |
|
27 | # Some IPython input | |
27 | ('In [1]: 1', '1'), |
|
28 | ('In [1]: 1', '1'), | |
28 | ('In [2]: for i in range(5):\n' |
|
29 | ('In [2]: for i in range(5):\n' | |
29 | ' ...: print i,', |
|
30 | ' ...: print i,', | |
30 | 'for i in range(5):\n' |
|
31 | 'for i in range(5):\n' | |
31 | ' print i,'), |
|
32 | ' print i,'), | |
32 | ] |
|
33 | ] | |
33 |
|
34 | |||
34 | for raw, correct in pairs: |
|
35 | for raw, correct in pairs: | |
35 | yield nt.assert_equals(ip.prefilter(raw), correct) |
|
36 | yield nt.assert_equals(ip.prefilter(raw), correct) | |
36 |
|
37 | |||
37 |
|
||||
38 | @dec.parametric |
|
38 | @dec.parametric | |
39 | def test_autocall_binops(): |
|
39 | def test_autocall_binops(): | |
40 | """See https://bugs.launchpad.net/ipython/+bug/315706""" |
|
40 | """See https://bugs.launchpad.net/ipython/+bug/315706""" | |
41 | ip.magic('autocall 2') |
|
41 | ip.magic('autocall 2') | |
42 | f = lambda x: x |
|
42 | f = lambda x: x | |
43 | ip.user_ns['f'] = f |
|
43 | ip.user_ns['f'] = f | |
44 | try: |
|
44 | try: | |
45 | yield nt.assert_equals(ip.prefilter('f 1'),'f(1)') |
|
45 | yield nt.assert_equals(ip.prefilter('f 1'),'f(1)') | |
46 | for t in ['f +1', 'f -1']: |
|
46 | for t in ['f +1', 'f -1']: | |
47 | yield nt.assert_equals(ip.prefilter(t), t) |
|
47 | yield nt.assert_equals(ip.prefilter(t), t) | |
48 | finally: |
|
48 | finally: | |
49 | ip.magic('autocall 0') |
|
49 | ip.magic('autocall 0') | |
50 | del ip.user_ns['f'] |
|
50 | del ip.user_ns['f'] | |
51 |
|
51 | |||
|
52 | @dec.parametric | |||
|
53 | def test_issue114(): | |||
|
54 | """Check that multiline string literals don't expand as magic | |||
|
55 | see http://github.com/ipython/ipython/issues/#issue/114""" | |||
|
56 | template = '"""\n%s\n"""' | |||
|
57 | for mgk in ip.lsmagic(): | |||
|
58 | raw = template % mgk | |||
|
59 | yield nt.assert_equals(ip.prefilter(raw), raw) |
General Comments 0
You need to be logged in to leave comments.
Login now