Show More
@@ -1,67 +1,66 b'' | |||
|
1 | 1 | """These kinds of tests are less than ideal, but at least they run. |
|
2 | 2 | |
|
3 | 3 | This was an old test that was being run interactively in the top-level tests/ |
|
4 | 4 | directory, which we are removing. For now putting this here ensures at least |
|
5 | 5 | we do run the test, though ultimately this functionality should all be tested |
|
6 | 6 | with better-isolated tests that don't rely on the global instance in iptest. |
|
7 | 7 | """ |
|
8 | 8 | from IPython.core.splitinput import LineInfo |
|
9 | 9 | from IPython.core.prefilter import AutocallChecker |
|
10 | from IPython.utils import py3compat | |
|
11 | 10 | |
|
12 | 11 | def doctest_autocall(): |
|
13 | 12 | """ |
|
14 | 13 | In [1]: def f1(a,b,c): |
|
15 | 14 | ...: return a+b+c |
|
16 | 15 | ...: |
|
17 | 16 | |
|
18 | 17 | In [2]: def f2(a): |
|
19 | 18 | ...: return a + a |
|
20 | 19 | ...: |
|
21 | 20 | |
|
22 | 21 | In [3]: def r(x): |
|
23 | 22 | ...: return True |
|
24 | 23 | ...: |
|
25 | 24 | |
|
26 | 25 | In [4]: ;f2 a b c |
|
27 | 26 | Out[4]: 'a b ca b c' |
|
28 | 27 | |
|
29 | 28 | In [5]: assert _ == "a b ca b c" |
|
30 | 29 | |
|
31 | 30 | In [6]: ,f1 a b c |
|
32 | 31 | Out[6]: 'abc' |
|
33 | 32 | |
|
34 | 33 | In [7]: assert _ == 'abc' |
|
35 | 34 | |
|
36 | 35 | In [8]: print(_) |
|
37 | 36 | abc |
|
38 | 37 | |
|
39 | 38 | In [9]: /f1 1,2,3 |
|
40 | 39 | Out[9]: 6 |
|
41 | 40 | |
|
42 | 41 | In [10]: assert _ == 6 |
|
43 | 42 | |
|
44 | 43 | In [11]: /f2 4 |
|
45 | 44 | Out[11]: 8 |
|
46 | 45 | |
|
47 | 46 | In [12]: assert _ == 8 |
|
48 | 47 | |
|
49 | 48 | In [12]: del f1, f2 |
|
50 | 49 | |
|
51 | 50 | In [13]: ,r a |
|
52 | 51 | Out[13]: True |
|
53 | 52 | |
|
54 | 53 | In [14]: assert _ == True |
|
55 | 54 | |
|
56 | 55 | In [15]: r'a' |
|
57 | 56 | Out[15]: 'a' |
|
58 | 57 | |
|
59 | 58 | In [16]: assert _ == 'a' |
|
60 | 59 | """ |
|
61 | 60 | |
|
62 | 61 | |
|
63 | 62 | def test_autocall_should_ignore_raw_strings(): |
|
64 | 63 | line_info = LineInfo("r'a'") |
|
65 | 64 | pm = ip.prefilter_manager |
|
66 | 65 | ac = AutocallChecker(shell=pm.shell, prefilter_manager=pm, config=pm.config) |
|
67 | 66 | assert ac.check(line_info) is None |
General Comments 0
You need to be logged in to leave comments.
Login now